All Flashcards
What is a wrapper class?
A class that encapsulates a primitive data type, allowing it to be treated as an object.
What is the Integer class?
A wrapper class for the primitive type int.
What is the Double class?
A wrapper class for the primitive type double.
What is autoboxing?
The automatic conversion of a primitive type to its corresponding wrapper class object.
What is unboxing?
The automatic conversion of a wrapper class object to its corresponding primitive type.
What are the differences between Integer.parseInt() and the Integer constructor?
Integer.parseInt() parses a String to an int. The Integer constructor creates an Integer object from an int or String.
What are the differences between Double.parseDouble() and the Double constructor?
Double.parseDouble() parses a String to a double. The Double constructor creates a Double object from a double or String.
How are wrapper classes used in data validation?
Wrapper classes can be used to represent nullable values in databases, which can be useful when a field is not required.
How are wrapper classes used in generic data structures?
Generic data structures like ArrayList<Integer> require objects, so wrapper classes are used to store primitive data.