AP Computer Science A Practice Quiz: Object Creation and Storage (Instantiation)
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Test your understanding with short quizzes. This quiz has 16 questions to check your progress.
Question 1 of 16
All Questions (16)
A) To perform a calculation and return a value.
B) To create objects of the class.
C) To declare variables for the class.
D) To define the class's name.
Correct Answer: B
The provided content states, 'A class contains constructors that are called to create objects.' Their primary purpose is instantiation.
A) It has the keyword `constructor` before its name.
B) It has the same name as the class.
C) It always has the name `init` or `create`.
D) It has no name, only parameters.
Correct Answer: B
The provided content explicitly states that constructors 'have the same name as the class.'
A) create
B) object
C) new
D) instance
Correct Answer: C
The provided content mentions, 'An object is typically created using the keyword new followed by a call to one of the class's constructors.'
A) new Robot myRobot;
B) Robot myRobot;
C) object Robot myRobot;
D) myRobot = Robot;
Correct Answer: B
This demonstrates the requirement to 'develop code to declare variables of the correct types to hold object references.' The correct syntax is `ClassName variableName;`.
A) The Student object itself.
B) A copy of the Student object.
C) The value null.
D) A reference to the Student object.
Correct Answer: D
The provided content states, 'A variable of a reference type holds an object reference'. The variable does not hold the object itself, but rather its location in memory (a reference).
A) An empty Dog object
B) The integer 0
C) null
D) An empty string ""
Correct Answer: C
The provided content states, 'A variable of a reference type holds an object reference or, if there is no object, null.' Since the variable is declared but not initialized with a `new` object, it holds `null`.
A) Book myBook = new Book();
B) new Book() = myBook;
C) Book myBook = Book();
D) myBook = new Book;
Correct Answer: A
This fulfills the requirement to 'develop code to create an object by calling a constructor.' The correct syntax combines declaration (`Book myBook`) with instantiation (`new Book()`) using the assignment operator and the `new` keyword.
A) public Car()
B) public Car(String modelName)
C) public Car(String modelName, int modelYear)
D) No constructor is called; this is a syntax error.
Correct Answer: B
This question tests the ability to 'Identify, using its signature, the correct constructor being called.' The call `new Car("Sedan")` provides one String argument, which matches the signature `public Car(String modelName)`.
A) Computer myComp = new Computer(16);
B) new Computer(8);
C) Computer myComp; myComp = new Computer(32);
D) Computer myComp = Computer(16);
Correct Answer: D
Object creation requires the `new` keyword. Option D is missing the `new` keyword, making it an invalid call to a constructor for the purpose of instantiation.
A) Song favorite = new Song("Happy Day");
B) String favorite = new Song("Happy Day");
C) Song("Happy Day") = favorite;
D) Song favorite = "Happy Day";
Correct Answer: A
This question requires developing code to declare a variable of the correct type (`Song favorite`) and to create an object by calling the appropriate constructor (`new Song("Happy Day")`). Option A correctly combines both steps.
A) `game1` holds a reference to a `Game` object, and `game2` holds `null`.
B) `game1` holds `null`, and `game2` holds a reference to a `Game` object.
C) Both `game1` and `game2` hold references to distinct `Game` objects.
D) Both `game1` and `game2` hold the value `null`.
Correct Answer: B
`game1` is only declared, so its value is `null`. `game2` is declared and instantiated with a new `Game` object, so it holds a reference to that object. This combines the concepts of declaration, instantiation, and the `null` value.
A) Box b1 = new Box(10);
B) Box b2 = new Box("Fragile");
C) Box b3 = new Box(5, 10);
D) Box b4 = new Box(10.5);
Correct Answer: D
The call `new Box(10.5)` passes a double-precision floating-point number as an argument. There is no constructor in the `Box` class that has a signature matching a single `double` parameter. The compiler cannot find a matching constructor to call.
A) The object it refers to has no data.
B) It does not currently refer to any object.
C) It refers to a special 'null object' that exists in memory.
D) The variable has not been declared.
Correct Answer: B
The provided content states that a reference variable holds `null` 'if there is no object.' It signifies the absence of an object.
A) newBicycle
B) createBicycle
C) Bicycle
D) It can be any valid method name.
Correct Answer: C
The content specifies that constructors 'have the same name as the class.' Therefore, any constructor for the `Bicycle` class must be named `Bicycle`.
A) The variable name and a semicolon.
B) The class name and a call to one of its constructors.
C) The data type and the variable name.
D) A call to a constructor and the object's memory address.
Correct Answer: B
The content states, 'An object is typically created using the keyword new followed by a call to one of the class's constructors.' A constructor call consists of the class name followed by parentheses with any necessary arguments.
A) It is `null`.
B) It refers to the same `Pen` object that `p1` originally referred to.
C) It refers to a new, distinct `Pen` object.
D) The code causes a runtime error.
Correct Answer: B
The line `Pen p2 = p1;` copies the reference from `p1` into `p2`. Both variables now point to the same object. The line `p1 = null;` changes only the `p1` variable to no longer refer to the object. The `p2` variable is unaffected and still holds the reference to the original `Pen` object.