AP Computer Science A Flashcards: Constructors
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.
Why is it important to initialize an instance variable with a copy of a mutable object parameter?
This prevents methods from modifying the state of the original object, as the instance variable does not hold a reference to it.
Card 1 of 10
All Flashcards (10)
Why is it important to initialize an instance variable with a copy of a mutable object parameter?
This prevents methods from modifying the state of the original object, as the instance variable does not hold a reference to it.
What is the default value for an uninitialized instance variable of type `boolean`?
The default value of an attribute of type boolean is false.
Where must the attributes that are to be initialized in a constructor be declared?
The attributes to be initialized in the body of a constructor must be declared as instance variables for the class.
What is the default value for an uninitialized instance variable of type `int`?
The default value for an attribute of type int is 0.
What is the default value for an uninitialized instance variable of a reference type?
The default value of a reference type attribute is null.
What is the primary purpose of a constructor?
A constructor is used to set the initial state of an object, which should include initial values for all instance variables.
What is the default value for an uninitialized instance variable of type `double`?
The default value of an attribute of type double is 0.0.
How do constructors receive data to initialize an object's instance variables?
Constructor parameters, if specified, provide the data that is used to initialize the instance variables of an object.
What is meant by 'setting the initial state of an object' in the context of a constructor?
It means the constructor is responsible for providing initial values for all of the object's instance variables.
If a constructor parameter is a mutable object, how should the corresponding instance variable be initialized?
The instance variable should be initialized with a copy of the referenced mutable object, not with a reference to the original object.