---
title: "Object Reference — AP Comp Sci A Definition & Exam Guide"
description: "An object reference is the memory address a reference-type variable holds, pointing to an object. It explains ==, null, aliasing, and parameter passing on AP CSA."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/object-reference"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 3"
---

# Object Reference — AP Comp Sci A Definition & Exam Guide

## Definition

In AP Computer Science A, an object reference is the value a reference-type variable actually holds, which you can think of as the memory address of an object (EK 1.12.B.1). The variable doesn't contain the object itself, just directions to where it lives, or null if it points to nothing.

## What It Is

When you write `Student s = new Student();`, the [variable](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr "fv-autolink") `s` does not hold the Student [object](/ap-comp-sci-a/key-terms/object "fv-autolink"). It holds an **object reference**, which the CED describes as something you can think of as the memory address of that object (EK 1.12.B.1). The object lives somewhere in memory, and the variable holds the directions to find it. If a reference variable doesn't point to any object yet, it holds `null` (EK 1.13.B.1).

This one idea explains a huge amount of weird-looking Java behavior. Two different variables can hold references to the same object, so changing the object through one variable changes what the other variable sees too (EK 2.6.B.1). Comparing references with `==` checks whether two variables point to the *same* object, not whether two objects look alike (EK 2.2.A.1). And when you pass an object to a [method](/ap-comp-sci-a/unit-3/abstraction-and-program-design/study-guide/o9VgVeIpKRYZ7N7rXfUz "fv-autolink"), Java copies the reference, not the object, so the method can reach back and modify the original mutable object (EK 3.6.A.1). Think of a reference like a home address written on a card. Copying the card doesn't build a second house, and anyone holding a copy can show up and repaint the real one.

## Why It Matters

Object references first appear in [Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink"), Topic 1.13 (Creating and Storing Objects), under LO 1.13.B, which asks you to declare variables of the correct types to hold object references. But the concept refuses to stay in Unit 1. LO 2.6.B (Unit 2) tests whether you can compare references with `==`, `!=`, and `null`. LO 3.6.A (Unit 3) tests whether you understand that methods receive a copy of the [reference](/ap-comp-sci-a/key-terms/reference "fv-autolink"), which is why a method can mutate an object passed to it. In Unit 4, arrays of objects store references (EK 4.3.A.1) and default to `null` (EK 4.3.A.3), ArrayLists contain object references (EK 4.8.A.1), and the enhanced for loop variable gets a copy of each element's reference, which is exactly why reassigning it does nothing (EK 4.4.A.4). If you misunderstand references, you will misread code in all four units. If you get them, half of Java's "gotcha" questions stop being gotchas.

## Connections

### == (Equality Operator) and equals (Unit 2)

With [reference types](/ap-comp-sci-a/key-terms/reference-type "fv-autolink"), `==` compares the references themselves, asking "do these two variables point to the same object in memory?" (EK 2.2.A.1, EK 2.6.B.1). The `equals` method, defined by a class, compares object contents instead. Two Strings with identical text can be `equals` but not `==`.

### [Call by Value (Units 1 & 3)](/ap-comp-sci-a/key-terms/call-by-value)

Java always passes arguments by value, but for objects the value being copied is the reference (EK 3.6.A.1). So the method gets its own copy of the address, not a copy of the object, which is why a method can change the state of a [mutable object](/ap-comp-sci-a/key-terms/mutable-object "fv-autolink") you pass in.

### Array Creation and Access (Unit 4)

An [array of objects](/ap-comp-sci-a/key-terms/array-of-objects "fv-autolink") is really an array of references, and `new` fills it with the default value `null` (EK 4.3.A.3). That's why calling a method on an element of a freshly created object array throws a NullPointerException until you actually construct objects for each slot.

### ArrayList Methods (Unit 4)

EK 4.8.A.1 says it directly. An ArrayList contains object references. Methods like `.get()` hand back the reference to the stored object, not a copy of it, so modifying what `.get()` returns modifies the object inside the list.

## On the AP Exam

Object references show up constantly in multiple-choice code-tracing questions. Common stems ask which declaration correctly holds a reference to an object of a given class, which superclass-typed variable can store references to multiple subclass objects (like a `Vehicle` variable holding `Car` and `Truck` references), and what `==` returns when two variables reference the same or different objects. You'll also trace code where two variables alias the same object and predict the output after one of them mutates it. On FRQs, references matter implicitly every time you write a method that takes an object parameter or returns an object. Remember that returning an object returns the reference, not a fresh copy (EK 3.6.A.2), and that checking a reference against `null` before calling methods on it is often the difference between full credit and a logic error.

## object reference vs Object (the instance itself)

The object is the actual instance sitting in memory with its attributes; the reference is the address-like value your variable holds that points to it (EK 1.12.A.1, EK 1.12.B.1). The line `Student s;` creates a reference variable but zero objects. Only `new Student()` builds an actual object. Mixing these up is why `null` errors and aliasing bugs feel mysterious. One object can have many references pointing at it, and a reference can exist with no object behind it at all.

## Key Takeaways

- A reference-type variable holds an object reference, which works like the memory address of the object, or null if no object exists yet (EK 1.12.B.1, EK 1.13.B.1).
- Two different variables can reference the same object, so a change made through one variable is visible through the other (EK 2.6.B.1).
- Using == on reference types compares the references, not the contents of the objects; use the class's equals method to compare contents (EK 2.2.A.1, EK 2.6.B.3).
- When an object is passed to a method, the parameter gets a copy of the reference, so the method can alter a mutable object's state but reassigning the parameter does nothing to the caller's variable (EK 3.6.A.1).
- Arrays and ArrayLists of objects actually store references, and object array elements default to null when the array is created (EK 4.3.A.3, EK 4.8.A.1).
- Assigning a new value to an enhanced for loop variable doesn't change the array, because that variable holds only a copy of each element's reference (EK 4.4.A.4).

## FAQs

### What is an object reference in AP Computer Science A?

It's the value a reference-type variable holds, which the CED says you can think of as the memory address of an object (EK 1.12.B.1). The variable points to the object rather than containing it, and it holds null if there's no object.

### Does == compare objects in Java?

No, not their contents. For reference types, == compares the references, so it returns true only when both variables point to the exact same object in memory (EK 2.2.A.1). To compare what's inside two objects, use the class's equals method.

### What's the difference between an object and an object reference?

The object is the instance itself, created with the keyword new and a constructor call (EK 1.13.C.1). The reference is the address-like value stored in your variable that points to that object. Declaring a variable creates a reference slot but never creates an object.

### If Java is call by value, why can a method change my object?

Because the value being copied is the reference. The method gets its own copy of the address, follows it to the same object, and can mutate that object's state (EK 3.6.A.1). It can't, however, make your original variable point somewhere new.

### Why do I get a NullPointerException with a new array of objects?

When you create an object array with new, every element defaults to null (EK 4.3.A.3). The array holds references, not objects, so you have to construct an object for each index before calling methods on the elements.

## Related Study Guides

- [3.6 Accessor Methods](/ap-comp-sci-a/unit-3/accessor-methods/study-guide/aGdfIlIw7aOvNseJG5R1)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/object-reference#resource","name":"Object Reference — AP Comp Sci A Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/object-reference","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/object-reference#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T05:27:18.458Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/object-reference#term","name":"object reference","description":"In AP Computer Science A, an object reference is the value a reference-type variable actually holds, which you can think of as the memory address of an object (EK 1.12.B.1). The variable doesn't contain the object itself, just directions to where it lives, or null if it points to nothing.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/object-reference","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is an object reference in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"It's the value a reference-type variable holds, which the CED says you can think of as the memory address of an object (EK 1.12.B.1). The variable points to the object rather than containing it, and it holds null if there's no object."}},{"@type":"Question","name":"Does == compare objects in Java?","acceptedAnswer":{"@type":"Answer","text":"No, not their contents. For reference types, == compares the references, so it returns true only when both variables point to the exact same object in memory (EK 2.2.A.1). To compare what's inside two objects, use the class's equals method."}},{"@type":"Question","name":"What's the difference between an object and an object reference?","acceptedAnswer":{"@type":"Answer","text":"The object is the instance itself, created with the keyword new and a constructor call (EK 1.13.C.1). The reference is the address-like value stored in your variable that points to that object. Declaring a variable creates a reference slot but never creates an object."}},{"@type":"Question","name":"If Java is call by value, why can a method change my object?","acceptedAnswer":{"@type":"Answer","text":"Because the value being copied is the reference. The method gets its own copy of the address, follows it to the same object, and can mutate that object's state (EK 3.6.A.1). It can't, however, make your original variable point somewhere new."}},{"@type":"Question","name":"Why do I get a NullPointerException with a new array of objects?","acceptedAnswer":{"@type":"Answer","text":"When you create an object array with new, every element defaults to null (EK 4.3.A.3). The array holds references, not objects, so you have to construct an object for each index before calling methods on the elements."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 3","item":"https://fiveable.me/ap-comp-sci-a/unit-3"},{"@type":"ListItem","position":4,"name":"object reference"}]}]}
```
