AP Computer Science a Flashcards: Wrapper Classes

Study Wrapper Classes in AP Computer Science a with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

AP Computer Science a

Wrapper Classes

0 mastered0 still learning

0% Complete

QUESTION
1/ 63

What is the wrapper class for the primitive type boolean?

Tap card or press Space to flip

ANSWER

Boolean. Direct correspondence between boolean primitive and Boolean wrapper.

How well did you know it?

Card 1 / 63

What this deck covers

This deck focuses on Wrapper Classes, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science a.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

All flashcards

Flashcard 1: What is the wrapper class for the primitive type boolean?

Answer: Boolean. Direct correspondence between boolean primitive and Boolean wrapper.

Flashcard 2: Identify unboxing in: int num = new Integer(10);

Answer: Integer object is unboxed to int. Wrapper object is automatically unwrapped to primitive type.

Flashcard 3: Identify the wrapper class for the primitive type float.

Answer: Float. Direct correspondence between float primitive and Float wrapper.

Flashcard 4: What is the result of Character.toUpperCase('a')?

Answer: 'A'. Converts lowercase 'a' to uppercase 'A'.

Flashcard 5: What is the result of Integer.compare(4, 5)?

Answer: -1. Returns negative since 4 is less than 5.

Flashcard 6: How do you get the int value from a String '123'?

Answer: Integer.parseInt("123"). Parses string to extract integer value.

Flashcard 7: How do you convert an Integer object to int?

Answer: IntegerObject.intValue(). Returns primitive int value from wrapper object.

Flashcard 8: Convert double 3.14 to its wrapper class object.

Answer: Double.valueOf(3.14). Uses valueOf() to create wrapper object from primitive.

Flashcard 9: Which method converts a Double object to double?

Answer: DoubleObject.doubleValue(). Returns primitive double value from wrapper object.

Flashcard 10: How do you convert Integer to String?

Answer: Integer.toString(). Converts Integer wrapper object to string representation.

Flashcard 11: What is the purpose of a wrapper class in Java?

Answer: To provide object equivalents for primitive data types. Allows primitives to be used in collections and as objects.

Flashcard 12: Identify autoboxing in: List list = new ArrayList<>(); list.add(5);

Answer: int 5 is autoboxed to Integer. Primitive int is automatically wrapped to fit Integer collection.

Flashcard 13: Identify unboxing in: int num = new Integer(10);

Answer: Integer object is unboxed to int. Wrapper object is automatically unwrapped to primitive type.

Flashcard 14: What does Long.parseLong("123456789") return?

Answer: 123456789L. Parses string to extract long value.

Flashcard 15: Which wrapper class corresponds to the primitive type char?

Answer: Character. Direct correspondence between char primitive and Character wrapper.

Flashcard 16: What is the result of Character.toUpperCase('a')?

Answer: 'A'. Converts lowercase 'a' to uppercase 'A'.

Flashcard 17: How do you convert an Integer object to int?

Answer: IntegerObject.intValue(). Returns primitive int value from wrapper object.

Flashcard 18: How do you get the int value from a String '123'?

Answer: Integer.parseInt("123"). Parses string to extract integer value.

Flashcard 19: How do you convert Boolean object to String?

Answer: BooleanObject.toString(). Converts Boolean object to its string representation.

Flashcard 20: Which method converts a String 'true' to a boolean?

Answer: Boolean.parseBoolean("true"). Parses string to extract boolean value.

Flashcard 21: Which wrapper class represents the primitive type int?

Answer: Integer. Direct correspondence between int primitive and Integer wrapper.

Flashcard 22: Which method converts String '5' to Integer?

Answer: Integer.valueOf("5"). Creates Integer wrapper object from string representation.

Flashcard 23: What is unboxing in Java?

Answer: Automatic conversion of wrapper class to primitive. Java automatically unwraps wrapper objects when needed.

Flashcard 24: Convert double 3.14 to its wrapper class object.

Answer: Double.valueOf(3.14). Uses valueOf() to create wrapper object from primitive.

Flashcard 25: Find the error: Integer i = new Integer("abc");

Answer: Throws NumberFormatException. Invalid string format cannot be converted to number.

Flashcard 26: Which method checks if a Character is a digit?

Answer: Character.isDigit(). Checks if character represents a numeric digit (0-9).

Flashcard 27: What is the purpose of a wrapper class in Java?

Answer: To provide object equivalents for primitive data types. Allows primitives to be used in collections and as objects.

Flashcard 28: Identify the wrapper class for the primitive type double.

Answer: Double. Direct correspondence between double primitive and Double wrapper.

Flashcard 29: What is autoboxing in Java?

Answer: Automatic conversion of primitive to wrapper class. Java automatically wraps primitives when needed.

Flashcard 30: How do you convert Boolean object to String?

Answer: BooleanObject.toString(). Converts Boolean object to its string representation.

Flashcard 31: Identify the wrapper class for the primitive type double.

Answer: Double. Direct correspondence between double primitive and Double wrapper.

Flashcard 32: Which method converts a Double object to double?

Answer: DoubleObject.doubleValue(). Returns primitive double value from wrapper object.

Flashcard 33: Which wrapper class has the method parseShort(String)?

Answer: Short. Short wrapper class provides parseShort() static method.

Flashcard 34: What is the wrapper class for the primitive type boolean?

Answer: Boolean. Direct correspondence between boolean primitive and Boolean wrapper.

Flashcard 35: How do you convert a String '3.14' to double?

Answer: Double.parseDouble("3.14"). Parses string to extract double value.

Flashcard 36: What method converts float to Float wrapper object?

Answer: Float.valueOf(float). Creates Float wrapper object from primitive float.

Flashcard 37: What is autoboxing in Java?

Answer: Automatic conversion of primitive to wrapper class. Java automatically wraps primitives when needed.

Flashcard 38: How do you convert a String '3.14' to double?

Answer: Double.parseDouble("3.14"). Parses string to extract double value.

Flashcard 39: Which method returns the byte value of an Integer?

Answer: IntegerObject.byteValue(). Converts Integer to byte primitive type.

Flashcard 40: What is the result of Boolean.compare(true, false)?

Answer:

  1. Returns positive since true is greater than false.

Flashcard 41: What is unboxing in Java?

Answer: Automatic conversion of wrapper class to primitive. Java automatically unwraps wrapper objects when needed.

Flashcard 42: Which method returns the byte value of an Integer?

Answer: IntegerObject.byteValue(). Converts Integer to byte primitive type.

Flashcard 43: How do you convert Integer to String?

Answer: Integer.toString(). Converts Integer wrapper object to string representation.

Flashcard 44: Which method returns the int value of a Byte object?

Answer: ByteObject.intValue(). Converts Byte wrapper to int primitive type.

Flashcard 45: What is the wrapper class for primitive type byte?

Answer: Byte. Direct correspondence between byte primitive and Byte wrapper.

Flashcard 46: Which method returns the int value of a Byte object?

Answer: ByteObject.intValue(). Converts Byte wrapper to int primitive type.

Flashcard 47: Convert int 5 to its wrapper class object.

Answer: Integer.valueOf(5). Uses valueOf() to create wrapper object from primitive.

Flashcard 48: What does Long.parseLong("123456789") return?

Answer: 123456789L. Parses string to extract long value.

Flashcard 49: Convert int 5 to its wrapper class object.

Answer: Integer.valueOf(5). Uses valueOf() to create wrapper object from primitive.

Flashcard 50: What method converts float to Float wrapper object?

Answer: Float.valueOf(float). Creates Float wrapper object from primitive float.

Flashcard 51: Which wrapper class corresponds to the primitive type char?

Answer: Character. Direct correspondence between char primitive and Character wrapper.

Flashcard 52: What method converts a Character object to char?

Answer: CharacterObject.charValue(). Returns primitive char value from wrapper object.

Flashcard 53: What is the result of Integer.compare(4, 5)?

Answer: -1. Returns negative since 4 is less than 5.

Flashcard 54: Which method checks if a Character is a digit?

Answer: Character.isDigit(). Checks if character represents a numeric digit (0-9).

Flashcard 55: Which method converts String '5' to Integer?

Answer: Integer.valueOf("5"). Creates Integer wrapper object from string representation.

Flashcard 56: What is the result of Boolean.compare(true, false)?

Answer:

  1. Returns positive since true is greater than false.

Flashcard 57: Which method converts a String 'true' to a boolean?

Answer: Boolean.parseBoolean("true"). Parses string to extract boolean value.

Flashcard 58: Identify autoboxing in: List list = new ArrayList<>(); list.add(5);

Answer: int 5 is autoboxed to Integer. Primitive int is automatically wrapped to fit Integer collection.

Flashcard 59: Identify the wrapper class for the primitive type float.

Answer: Float. Direct correspondence between float primitive and Float wrapper.

Flashcard 60: Which wrapper class represents the primitive type int?

Answer: Integer. Direct correspondence between int primitive and Integer wrapper.

Flashcard 61: What method converts a Character object to char?

Answer: CharacterObject.charValue(). Returns primitive char value from wrapper object.

Flashcard 62: How do you convert '123.45' to Float?

Answer: Float.parseFloat("123.45"). Parses string to extract float value as Float object.

Flashcard 63: Find the error: Integer i = new Integer("abc");

Answer: Throws NumberFormatException. Invalid string format cannot be converted to number.