AP Computer Science A Flashcards: Wrapper Classes
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.
To which Java package do the Integer and Double classes belong?
The Integer class and Double class are part of the java.lang package.
Card 1 of 10
All Flashcards (10)
To which Java package do the Integer and Double classes belong?
The Integer class and Double class are part of the java.lang package.
What automatic conversion occurs in the line: `int newInt = myInteger;` (assuming `myInteger` is an Integer object)?
This is an example of unboxing, where the Integer object `myInteger` is automatically converted to its primitive `int` value.
What does it mean for an Integer or Double object to be immutable?
An immutable object is one whose value cannot be changed after it is created. Both Integer and Double objects are immutable.
What is unboxing?
Unboxing is the automatic conversion that the Java compiler makes from the wrapper class to the primitive type (e.g., Integer to int).
What automatic conversion occurs in the line: `Integer myInt = 100;`?
This is an example of autoboxing, where the primitive `int` value 100 is automatically converted to an Integer object.
What is the Integer class?
The Integer class is an immutable wrapper class for the primitive type `int`, allowing an int value to be used as an object.
What is the Double class?
The Double class is an immutable wrapper class for the primitive type `double`, allowing a double value to be used as an object.
What is autoboxing?
Autoboxing is the automatic conversion that the Java compiler makes between primitive types and their corresponding object wrapper classes (e.g., int to Integer).
What is a key property of an Integer object after its creation?
An Integer object is immutable, meaning its internal value cannot be changed once the object has been created.
Consider the code: `Double d = 20.5;`. Which automatic conversion is demonstrated?
This code demonstrates autoboxing, as the primitive `double` literal 20.5 is automatically converted to a Double object.