PrepGo

AP Computer Science A Flashcards: Object Creation and Storage (Instantiation)

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.

What is a constructor?
A constructor is a special method within a class that is called to create objects. It always has the same name as the class.
Card 1 of 10

All Flashcards (10)

What is a constructor?
A constructor is a special method within a class that is called to create objects. It always has the same name as the class.
How do you identify the specific constructor being called when creating an object?
The correct constructor is identified by its signature, which is the combination of the constructor's name and the list of its parameter types.
Develop the code to declare a variable named `myStudent` to hold a reference to a `Student` object.
`Student myStudent;` This line of code declares a variable of the correct type (`Student`) to hold an object reference.
What does it mean if an object reference variable holds the value `null`?
If a reference variable is `null`, it means that it does not currently refer to or point to any object in memory.
Write a single line of code that declares a `Dog` variable named `fido` and instantiates a new `Dog` object for it using the default constructor.
`Dog fido = new Dog();` This code both declares the reference variable `fido` and assigns it a reference to a newly created `Dog` object.
What does a variable of a reference type hold?
A variable of a reference type holds an object reference, which is the memory address of an object, or it holds the value `null` if it doesn't point to an object.
Develop the code to create an object of the `Game` class by calling its default constructor.
`new Game();` This expression creates a new `Game` object by using the `new` keyword and calling the `Game` constructor.
Given the code `Bicycle myBike = new Bicycle();`, which part is the constructor call?
The constructor call in this statement is `Bicycle()`. It has the same name as the class and is used to create the object.
What is the purpose of the `new` keyword?
The `new` keyword is used to create an instance of an object by allocating memory and invoking one of the class's constructors.
What are the two essential components of an expression that creates an object?
The expression must include the `new` keyword, which allocates memory, followed by a call to one of the class's constructors, which initializes the object.