PrepGo

AP Computer Science A Practice Quiz: Objects: Instances of Classes

Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026

Test your understanding with short quizzes. This quiz has 14 questions to check your progress.

Question 1 of 14

Which of the following best describes a class?

All Questions (14)

Which of the following best describes a class?

A) A specific instance with defined attributes.

B) The memory address of an object.

C) A blueprint for creating objects.

D) A variable that holds an object reference.

Correct Answer: C

The provided content states that 'A class is the formal implementation, or blueprint, of the attributes and behaviors of an object.'

What is an object in the context of object-oriented programming?

A) A formal implementation of attributes and behaviors.

B) A specific instance of a class.

C) A collection of common attributes for related classes.

D) The memory address where a class is stored.

Correct Answer: B

The content defines an object as 'a specific instance of a class with defined attributes.'

Which statement accurately describes the relationship between a class and an object?

A) A class is an instance of an object.

B) An object is a blueprint for a class.

C) A class and an object are two terms for the same concept.

D) An object is created from the template defined by a class.

Correct Answer: D

A class acts as a blueprint or template, and an object is a specific instance created based on that template, as described in the provided content.

Consider the following line of code: `Car myCar;` Assuming `Car` is a class, what does this line of code accomplish?

A) It creates a new `Car` object.

B) It declares a variable named `myCar` that can hold a reference to a `Car` object.

C) It defines the `Car` class.

D) It assigns a memory address to the `Car` class.

Correct Answer: B

This code declares a variable of a reference type. The variable `myCar` is created to hold a reference (or memory address) to a `Car` object, but it does not create the object itself.

What does a variable of a reference type store?

A) The object itself.

B) The blueprint of the class.

C) The memory address of an object.

D) The common attributes of a superclass.

Correct Answer: C

The content explicitly states that 'A variable of a reference type holds an object reference, which can be thought of as the memory address of that object.'

In a class hierarchy, what is the role of a superclass?

A) To be a specific instance of another class.

B) To extend the attributes and behaviors of another class.

C) To contain common attributes and behaviors for related classes.

D) To hold the memory address of a subclass.

Correct Answer: C

The definition provided states that a superclass is a 'single class' used for 'putting common attributes and behaviors of related classes.'

In object-oriented programming, what is a subclass?

A) A class that contains common attributes for other classes.

B) A class that extends a superclass.

C) A blueprint for creating superclasses.

D) A specific instance of a superclass.

Correct Answer: B

The content defines subclasses as 'Classes that extend a superclass.'

If a programmer designs a `Book` class to model the properties of books, and then creates a specific book titled `The Great Gatsby` in their program, which of the following is true?

A) `Book` is the object, and `The Great Gatsby` is the class.

B) `Book` is the class, and `The Great Gatsby` is the object.

C) Both `Book` and `The Great Gatsby` are classes.

D) Both `Book` and `The Great Gatsby` are objects.

Correct Answer: B

`Book` is the blueprint or formal implementation (the class), while the specific book `The Great Gatsby` is a specific instance of that blueprint (the object).

What is an 'object reference'?

A) A formal implementation of an object's behaviors.

B) A value that can be thought of as the memory address of an object.

C) A special type of class that contains common attributes.

D) The process of creating a new instance of a class.

Correct Answer: B

The provided text explicitly states that an object reference 'can be thought of as the memory address of that object.'

If `Animal` is a superclass, and `Dog` and `Cat` are subclasses, what does this structure primarily allow a programmer to do?

A) Create specific instances of the `Animal` class.

B) Place common attributes, like `age` or `name`, into the `Animal` class to be shared by `Dog` and `Cat`.

C) Ensure that `Dog` and `Cat` objects have different memory addresses.

D) Define the `Dog` and `Cat` classes as blueprints for the `Animal` class.

Correct Answer: B

The purpose of a class hierarchy is to put 'common attributes and behaviors of related classes into a single class called a superclass.' This avoids code duplication.

After the statement `String message;` is executed, which of the following is true?

A) A `String` object has been created and is stored in `message`.

B) The `String` class has been defined.

C) The variable `message` has been created but does not yet refer to a specific `String` object.

D) The variable `message` holds the memory address of the `String` class itself.

Correct Answer: C

Declaring a reference variable only creates a variable that can hold a reference to an object. It does not create the object itself. The variable `message` is initialized to a null reference.

The primary purpose of creating a class hierarchy with superclasses and subclasses is to:

A) Ensure every object has a unique memory address.

B) Organize related classes and reuse code for common attributes and behaviors.

C) Create specific instances from a blueprint.

D) Declare variables that can store object references.

Correct Answer: B

The text explains that a class hierarchy is developed by putting 'common attributes and behaviors' into a superclass, which is a key principle of code reuse and organization.

According to the provided text, a class is the formal implementation of an object's...

A) memory address and reference type.

B) superclass and subclasses.

C) attributes and behaviors.

D) specific instance and hierarchy.

Correct Answer: C

The definition given is that 'A class is the formal implementation, or blueprint, of the attributes and behaviors of an object.'

Which analogy best represents the relationship between a class and an object?

A) A class is to an object as a recipe is to a specific cake that was baked.

B) A class is to an object as a driver is to a car.

C) A class is to an object as a house is to a specific room in that house.

D) A class is to an object as an ingredient is to a recipe.

Correct Answer: A

A recipe (the class) is the set of instructions or blueprint, while the specific cake baked from it (the object) is the actual instance. This aligns with the definition of a class as a blueprint.