Wrapper Classes - AP Computer Science A
Card 1 of 30
Which method returns the int value of a Byte object?
Which method returns the int value of a Byte object?
Tap to reveal answer
ByteObject.intValue(). Converts Byte wrapper to int primitive type.
ByteObject.intValue(). Converts Byte wrapper to int primitive type.
← Didn't Know|Knew It →
What is the result of Character.toUpperCase('a')?
What is the result of Character.toUpperCase('a')?
Tap to reveal answer
'A'. Converts lowercase 'a' to uppercase 'A'.
'A'. Converts lowercase 'a' to uppercase 'A'.
← Didn't Know|Knew It →
Identify unboxing in: int num = new Integer(10);
Identify unboxing in: int num = new Integer(10);
Tap to reveal answer
Integer object is unboxed to int. Wrapper object is automatically unwrapped to primitive type.
Integer object is unboxed to int. Wrapper object is automatically unwrapped to primitive type.
← Didn't Know|Knew It →
Which method returns the byte value of an Integer?
Which method returns the byte value of an Integer?
Tap to reveal answer
IntegerObject.byteValue(). Converts Integer to byte primitive type.
IntegerObject.byteValue(). Converts Integer to byte primitive type.
← Didn't Know|Knew It →
Identify the wrapper class for the primitive type float.
Identify the wrapper class for the primitive type float.
Tap to reveal answer
Float. Direct correspondence between float primitive and Float wrapper.
Float. Direct correspondence between float primitive and Float wrapper.
← Didn't Know|Knew It →
What is the result of Boolean.compare(true, false)?
What is the result of Boolean.compare(true, false)?
Tap to reveal answer
- Returns positive since true is greater than false.
- Returns positive since true is greater than false.
← Didn't Know|Knew It →
Which wrapper class has the method parseShort(String)?
Which wrapper class has the method parseShort(String)?
Tap to reveal answer
Short. Short wrapper class provides parseShort() static method.
Short. Short wrapper class provides parseShort() static method.
← Didn't Know|Knew It →
How do you convert '123.45' to Float?
How do you convert '123.45' to Float?
Tap to reveal answer
Float.parseFloat("123.45"). Parses string to extract float value as Float object.
Float.parseFloat("123.45"). Parses string to extract float value as Float object.
← Didn't Know|Knew It →
What is the wrapper class for primitive type byte?
What is the wrapper class for primitive type byte?
Tap to reveal answer
Byte. Direct correspondence between byte primitive and Byte wrapper.
Byte. Direct correspondence between byte primitive and Byte wrapper.
← Didn't Know|Knew It →
What does Long.parseLong("123456789") return?
What does Long.parseLong("123456789") return?
Tap to reveal answer
123456789L. Parses string to extract long value.
123456789L. Parses string to extract long value.
← Didn't Know|Knew It →
Which method checks if a Character is a digit?
Which method checks if a Character is a digit?
Tap to reveal answer
Character.isDigit(). Checks if character represents a numeric digit (0-9).
Character.isDigit(). Checks if character represents a numeric digit (0-9).
← Didn't Know|Knew It →
How do you convert Integer to String?
How do you convert Integer to String?
Tap to reveal answer
Integer.toString(). Converts Integer wrapper object to string representation.
Integer.toString(). Converts Integer wrapper object to string representation.
← Didn't Know|Knew It →
Identify autoboxing in: List list = new ArrayList<>(); list.add(5);
Identify autoboxing in: List
Tap to reveal answer
int 5 is autoboxed to Integer. Primitive int is automatically wrapped to fit Integer collection.
int 5 is autoboxed to Integer. Primitive int is automatically wrapped to fit Integer collection.
← Didn't Know|Knew It →
Which method converts String '5' to Integer?
Which method converts String '5' to Integer?
Tap to reveal answer
Integer.valueOf("5"). Creates Integer wrapper object from string representation.
Integer.valueOf("5"). Creates Integer wrapper object from string representation.
← Didn't Know|Knew It →
Find the error: Integer i = new Integer("abc");
Find the error: Integer i = new Integer("abc");
Tap to reveal answer
Throws NumberFormatException. Invalid string format cannot be converted to number.
Throws NumberFormatException. Invalid string format cannot be converted to number.
← Didn't Know|Knew It →
Which wrapper class represents the primitive type int?
Which wrapper class represents the primitive type int?
Tap to reveal answer
Integer. Direct correspondence between int primitive and Integer wrapper.
Integer. Direct correspondence between int primitive and Integer wrapper.
← Didn't Know|Knew It →
What is the wrapper class for the primitive type boolean?
What is the wrapper class for the primitive type boolean?
Tap to reveal answer
Boolean. Direct correspondence between boolean primitive and Boolean wrapper.
Boolean. Direct correspondence between boolean primitive and Boolean wrapper.
← Didn't Know|Knew It →
Convert double 3.14 to its wrapper class object.
Convert double 3.14 to its wrapper class object.
Tap to reveal answer
Double.valueOf(3.14). Uses valueOf() to create wrapper object from primitive.
Double.valueOf(3.14). Uses valueOf() to create wrapper object from primitive.
← Didn't Know|Knew It →
How do you convert an Integer object to int?
How do you convert an Integer object to int?
Tap to reveal answer
IntegerObject.intValue(). Returns primitive int value from wrapper object.
IntegerObject.intValue(). Returns primitive int value from wrapper object.
← Didn't Know|Knew It →
Which method converts a Double object to double?
Which method converts a Double object to double?
Tap to reveal answer
DoubleObject.doubleValue(). Returns primitive double value from wrapper object.
DoubleObject.doubleValue(). Returns primitive double value from wrapper object.
← Didn't Know|Knew It →
What method converts a Character object to char?
What method converts a Character object to char?
Tap to reveal answer
CharacterObject.charValue(). Returns primitive char value from wrapper object.
CharacterObject.charValue(). Returns primitive char value from wrapper object.
← Didn't Know|Knew It →
How do you get the int value from a String '123'?
How do you get the int value from a String '123'?
Tap to reveal answer
Integer.parseInt("123"). Parses string to extract integer value.
Integer.parseInt("123"). Parses string to extract integer value.
← Didn't Know|Knew It →
Which method converts a String 'true' to a boolean?
Which method converts a String 'true' to a boolean?
Tap to reveal answer
Boolean.parseBoolean("true"). Parses string to extract boolean value.
Boolean.parseBoolean("true"). Parses string to extract boolean value.
← Didn't Know|Knew It →
How do you convert a String '3.14' to double?
How do you convert a String '3.14' to double?
Tap to reveal answer
Double.parseDouble("3.14"). Parses string to extract double value.
Double.parseDouble("3.14"). Parses string to extract double value.
← Didn't Know|Knew It →
What is autoboxing in Java?
What is autoboxing in Java?
Tap to reveal answer
Automatic conversion of primitive to wrapper class. Java automatically wraps primitives when needed.
Automatic conversion of primitive to wrapper class. Java automatically wraps primitives when needed.
← Didn't Know|Knew It →
What is unboxing in Java?
What is unboxing in Java?
Tap to reveal answer
Automatic conversion of wrapper class to primitive. Java automatically unwraps wrapper objects when needed.
Automatic conversion of wrapper class to primitive. Java automatically unwraps wrapper objects when needed.
← Didn't Know|Knew It →
Identify autoboxing in: List list = new ArrayList<>(); list.add(5);
Identify autoboxing in: List
Tap to reveal answer
int 5 is autoboxed to Integer. Primitive int is automatically wrapped to fit Integer collection.
int 5 is autoboxed to Integer. Primitive int is automatically wrapped to fit Integer collection.
← Didn't Know|Knew It →
What is the purpose of a wrapper class in Java?
What is the purpose of a wrapper class in Java?
Tap to reveal answer
To provide object equivalents for primitive data types. Allows primitives to be used in collections and as objects.
To provide object equivalents for primitive data types. Allows primitives to be used in collections and as objects.
← Didn't Know|Knew It →
Which method converts a String 'true' to a boolean?
Which method converts a String 'true' to a boolean?
Tap to reveal answer
Boolean.parseBoolean("true"). Parses string to extract boolean value.
Boolean.parseBoolean("true"). Parses string to extract boolean value.
← Didn't Know|Knew It →
Identify the wrapper class for the primitive type double.
Identify the wrapper class for the primitive type double.
Tap to reveal answer
Double. Direct correspondence between double primitive and Double wrapper.
Double. Direct correspondence between double primitive and Double wrapper.
← Didn't Know|Knew It →