---
title: "AP CSA 1.12: Objects as Instances of Classes"
description: "Learn how classes and objects relate in AP Computer Science A. Understand reference variables, object references, and the Java class hierarchy for the exam."
canonical: "https://fiveable.me/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe"
type: "study-guide"
subject: "AP Computer Science A"
unit: "Unit 1 – Using Objects and Methods"
lastUpdated: "2026-06-08"
---

# AP CSA 1.12: Objects as Instances of Classes

## Summary

Learn how classes and objects relate in AP Computer Science A. Understand reference variables, object references, and the Java class hierarchy for the exam.

## Guide

## TLDR
A class is the blueprint, and an [object](/ap-comp-sci-a/key-terms/object "fv-autolink") is a specific instance built from that blueprint with its own attribute values. In [AP Computer Science A](/ap-comp-sci-a "fv-autolink"), a variable of a reference type does not hold the object itself; it holds a reference to where the object lives in memory. Topic 1.12 is where you start thinking in terms of objects, references, and how every Java class connects back to the built-in Object class.

## Why This Matters for the AP Computer Science A Exam

This topic builds the mental model you use for the rest of the course. Once you understand that an object is an instance of a class and that reference variables store references rather than raw values, everything from [String methods](/ap-comp-sci-a/unit-1/string-methods/study-guide/SltCtk8JxBIgHcMfG6G4 "fv-autolink") to ArrayLists to [2D arrays](/ap-comp-sci-a/unit-4/2d-arrays/study-guide/5WDx6ZFeWhx2aVuiZI6R "fv-autolink") makes more sense.

On the exam, this shows up most in multiple-choice questions where you describe the behavior of a code segment. You will be expected to tell the difference between a class and an object, recognize that two objects of the same class can hold different data, and understand what a [reference variable](/ap-comp-sci-a/key-terms/reference-variable "fv-autolink") actually stores. Later free-response code writing also depends on this foundation, since you cannot work with objects you do not understand.

A few [scope](/ap-comp-sci-a/unit-3/scope-and-access/study-guide/56FUK4RSofr7slzwm6xm "fv-autolink") notes so you do not overstudy. You should know that subclasses extend a superclass and inherit its attributes and [behaviors](/ap-comp-sci-a/key-terms/behavior "fv-autolink"), and that every class in Java is ultimately a subclass of Object. You do not need to design or write inheritance relationships yourself in this course. Keep your focus on explaining the class-object relationship and declaring reference variables correctly.

## Key Takeaways

- A class is the blueprint that defines attributes and behaviors; an object is a specific instance of that class with its own attribute values.
- Two objects of the same class share the same methods but can store completely different data.
- A reference variable holds an [object reference](/ap-comp-sci-a/key-terms/object-reference "fv-autolink"), which you can think of as the memory address of the object, not the object itself.
- A reference variable can hold `null`, meaning it is not pointing to any object yet.
- Subclasses extend a superclass and inherit its attributes and behaviors, and every class in Java is a subclass of `Object`.
- You are responsible for explaining class-object relationships and declaring reference types, not for designing inheritance.

## Class vs Object

A class is the formal blueprint of the attributes and behaviors an object will have. An object is a specific instance of that class with defined attributes. If `Car` is the class, then one actual car you build from it is an object.

Each object keeps its own state through its attributes while sharing the same methods defined by the class. That is why two objects of the same type can behave the same way but hold different data.

```java
// Car is the class (blueprint)
public class Car {
    private String make;
    private String model;
    private int year;

    public Car(String carMake, String carModel, int carYear) {
        make = carMake;
        model = carModel;
        year = carYear;
    }

    public String getCarInfo() {
        return year + " " + make + " " + model;
    }
}
```

```java
// Each variable below refers to a separate Car object
Car myCar = new Car("Toyota", "Camry", 2020);
Car friendsCar = new Car("Honda", "Civic", 2019);

System.out.println(myCar.getCarInfo());      // 2020 Toyota Camry
System.out.println(friendsCar.getCarInfo()); // 2019 Honda Civic
```

`myCar` and `friendsCar` are both `Car` objects, but they store different attribute values and are completely independent.

## Reference Variables and References

This is the part that trips people up. A variable of a reference type does not store the object. It stores a reference to the object, which you can think of as the memory address where the object actually lives.

```java
Car myCar = new Car("Toyota", "Camry", 2020);
```

Here, `myCar` does not contain the car's data directly. It holds a reference that points to the `Car` object created by `new`. When you call `myCar.getCarInfo()`, Java follows that reference to find the object and run the method.

A reference variable can also hold `null`, which means it is not pointing to any object. Declaring a variable and creating an object are two separate steps.

```java
Car myCar;        // declared, currently holds null (no object yet)
myCar = new Car("Toyota", "Camry", 2020); // now refers to a real object
```

## Classes Are Reference Types

Classes define reference types, the same way `int`, `double`, and `boolean` are [primitive types](/ap-comp-sci-a/key-terms/primitive-types "fv-autolink"). When you write `int x = 5;`, `x` holds the value 5 directly. When you write `Car myCar = new Car("Toyota", "Camry", 2020);`, `myCar` holds a reference to a `Car` object, not the object itself.

Every object created from a class has the same structure defined by that class, but each can store different data.

## Where Object Fits In

Java organizes related classes using a hierarchy. Common attributes and behaviors can be placed in a single class called a superclass. Classes that extend a superclass, called subclasses, can use the superclass's existing attributes and behaviors without rewriting them. This is an inheritance relationship.

The big fact to remember: every class in Java is ultimately a subclass of the built-in `Object` class. You do not need to design or implement inheritance in this course, but knowing that all classes trace back to `Object` helps later when you see behaviors that every object is guaranteed to have.

## How to Use This on the AP Computer Science A Exam

### MCQ

- When a question asks you to describe behavior, separate the class from its objects. The class defines what attributes and methods exist; each object holds its own values.
- Expect questions where two objects of the same class store different data. Track each [object's state](/ap-comp-sci-a/key-terms/objects-state "fv-autolink") separately.
- Know that a reference variable stores a reference, not the object. Questions may test whether you understand that two variables could refer to the same object or to different objects.
- If a variable was declared but never assigned an object, it holds `null`.

### Code Tracing

- When you see `new ClassName(...)`, recognize that a new object is being created and a reference to it is stored in the variable.
- Follow each reference variable to the object it points to before predicting output.
- Keep separate notes for each object so you do not mix up their attribute values.

### Common Trap

- Declaring a variable does not create an object. `Car myCar;` gives you a variable that holds `null` until you assign it an object with `new`.

## Common Misconceptions

- "A class and an object are the same thing." A class is the blueprint. An object is a specific instance built from that blueprint. One class can produce many independent objects.
- "A reference variable stores the object." It stores a reference to the object, which you can think of as a memory address. The object itself lives elsewhere in memory.
- "Declaring a variable creates the object." Declaration and creation are separate. Until you assign an object with `new`, the reference variable holds `null`.
- "Changing one object changes all objects of that class." Each object keeps its own attribute values. Changing one object's data does not affect another object of the same class.
- "I need to write inheritance code for this topic." You only need to explain the class-object relationship and declare reference variables. Designing and implementing inheritance is not part of this topic.
- "Every class extending Object is something I set up." Every Java class is automatically a subclass of `Object`. You do not write that relationship yourself.

## Related AP Computer Science A Guides

- [1.4 Assignment Statements and Input](/ap-comp-sci-a/unit-1/14-assignment-statement-input/study-guide/compoundassignment)
- [1.14 Calling a Void Method](/ap-comp-sci-a/unit-1/calling-a-void-method/study-guide/0RaM4GVOnbikS9dDp971)
- [1.6 Compound Assignment Operators](/ap-comp-sci-a/unit-1/compound-assignment-operators/study-guide/JiszeHqK8F9G6gszbgPL)
- [1.15 String Methods](/ap-comp-sci-a/unit-1/string-methods/study-guide/SltCtk8JxBIgHcMfG6G4)
- [1.1 Why Programming? Why Java?](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z)
- [1.11 Using the Math Class](/ap-comp-sci-a/unit-1/using-the-math-class/study-guide/6e652tzJOa5eE5mjPATE)

## Vocabulary

- **attribute**: The data or properties that define the state of an object or class.
- **behavior**: The methods or actions that an object or class can perform.
- **class**: A formal implementation or blueprint that defines the attributes and behaviors of objects.
- **inheritance**: A relationship in which a subclass draws upon and reuses the attributes and behaviors of a superclass.
- **instance**: A specific occurrence or realization of a class with its own set of attribute values.
- **memory address**: The location in computer memory where an object is stored, which is referenced by a reference type variable.
- **object**: A specific instance of a class with defined attributes and behaviors.
- **object reference**: A value that points to the memory location where an object is stored, allowing access to that object.
- **reference type**: A data type that holds a reference (memory address) to an object rather than storing the object's value directly.
- **subclass**: A class that extends a superclass and inherits its attributes and behaviors.
- **superclass**: A class that contains common attributes and behaviors shared by multiple related classes.

## FAQs

### What is the difference between a class and an object?

A class is a blueprint that defines attributes and behaviors. An object is a specific instance of that class, with its own stored data for the attributes.

### What is an object reference in Java?

An object reference is the value stored in a reference variable that points to an object. For AP CSA, think of it as a memory-address-like reference rather than the object itself.

### What does null mean for a reference variable?

A reference variable with the value null does not currently refer to any object. Trying to use it as if it refers to an object can cause a NullPointerException.

### Can two objects of the same class store different data?

Yes. Two objects can be created from the same class and still store different attribute values. They share the same class definition but have separate object state.

### What is the Object class in Java?

Object is the top class in Java's class hierarchy. All Java classes are subclasses of Object, even when that relationship is not written explicitly.

### Do I need to implement inheritance for AP CSA Topic 1.12?

No. For Topic 1.12, you should understand the idea of a class hierarchy and that all Java classes are subclasses of Object, but designing or implementing inheritance is outside this topic.

## Structured Data

```json
{"@context":"https://schema.org","@type":"FAQPage","inLanguage":"en","mainEntity":[{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe#what-is-the-difference-between-a-class-and-an-object","name":"What is the difference between a class and an object?","acceptedAnswer":{"@type":"Answer","text":"A class is a blueprint that defines attributes and behaviors. An object is a specific instance of that class, with its own stored data for the attributes."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe#what-is-an-object-reference-in-java","name":"What is an object reference in Java?","acceptedAnswer":{"@type":"Answer","text":"An object reference is the value stored in a reference variable that points to an object. For AP CSA, think of it as a memory-address-like reference rather than the object itself."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe#what-does-null-mean-for-a-reference-variable","name":"What does null mean for a reference variable?","acceptedAnswer":{"@type":"Answer","text":"A reference variable with the value null does not currently refer to any object. Trying to use it as if it refers to an object can cause a NullPointerException."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe#can-two-objects-of-the-same-class-store-different-data","name":"Can two objects of the same class store different data?","acceptedAnswer":{"@type":"Answer","text":"Yes. Two objects can be created from the same class and still store different attribute values. They share the same class definition but have separate object state."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe#what-is-the-object-class-in-java","name":"What is the Object class in Java?","acceptedAnswer":{"@type":"Answer","text":"Object is the top class in Java's class hierarchy. All Java classes are subclasses of Object, even when that relationship is not written explicitly."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe#do-i-need-to-implement-inheritance-for-ap-csa-topic-112","name":"Do I need to implement inheritance for AP CSA Topic 1.12?","acceptedAnswer":{"@type":"Answer","text":"No. For Topic 1.12, you should understand the idea of a class hierarchy and that all Java classes are subclasses of Object, but designing or implementing inheritance is outside this topic."}}]}
```
