---
title: "Reference — AP Comp Sci A Definition & Exam Guide"
description: "A reference is a variable that holds the memory address of an object, not the object itself. Master aliasing, null, and reference vs. primitive for AP CSA."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/reference"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 1"
---

# Reference — AP Comp Sci A Definition & Exam Guide

## Definition

In AP Computer Science A, a reference is the value stored in a variable of a reference type: essentially the memory address of an object, not the object itself (EK 1.12.B.1). Two variables can hold references to the same object, so changing the object through one variable is visible through the other.

## What It Is

A **reference** is what actually lives inside a [variable](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr "fv-autolink") like `Student s` or `ArrayList<String> list`. The variable doesn't contain the [object](/ap-comp-sci-a/key-terms/object "fv-autolink"). It contains a pointer to where the object sits in memory. The CED puts it plainly in EK 1.12.B.1: a variable of a reference type holds an object reference, "which can be thought of as the memory address of that object."

Think of it like a home address written on a sticky note. Copying the sticky note (`list3 = list1`) doesn't build a second house. It gives you two notes pointing at the same house, so if someone repaints the house, both notes lead you to the repainted version. That's why `list3 = list1; list1.add("Java");` means `list3` sees "Java" too. This is called **aliasing**, and it's the single biggest reason references trip people up. A reference variable can also hold `null`, meaning it points at nothing yet, and calling a [method](/ap-comp-sci-a/unit-3/abstraction-and-program-design/study-guide/o9VgVeIpKRYZ7N7rXfUz "fv-autolink") on it throws a `NullPointerException`.

## Why It Matters

References live in **Topic 1.12 (Objects: Instances of Classes)** in **[Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink"): Using Objects and Methods**, under learning objective **1.12.B**: develop code to declare variables to store [reference types](/ap-comp-sci-a/key-terms/reference-type "fv-autolink"). They sit right next to 1.12.A, which covers classes as blueprints and objects as instances. A class is the blueprint, `new` builds the object, and the reference is your handle on that object.

This concept never stops mattering. Every `String`, every `ArrayList`, every object you create in an FRQ is accessed through a reference. If you don't understand that `=` copies the address (not the object), you'll misread MCQ trace questions about aliasing, mutability, and `null`, and you'll be confused about why methods can change an object you passed in.

## Connections

### [Object reference (Unit 1)](/ap-comp-sci-a/key-terms/object-reference)

This is the exact CED phrase for the value a [reference variable](/ap-comp-sci-a/key-terms/reference-variable "fv-autolink") holds. "Reference" and "object reference" are the same idea: the variable stores the address, and the object lives elsewhere in memory.

### Attributes and behaviors of objects (Unit 1)

A reference is useless on its own. Its whole job is letting you use the [dot operator](/ap-comp-sci-a/key-terms/dot-operator "fv-autolink") to reach an object's attributes and call its behaviors, like `student1.getName()`. No reference, no access.

### Aliasing in arrays and ArrayLists (Unit 4)

Arrays and ArrayLists store references, and array/[list](/ap-comp-sci-a/key-terms/list "fv-autolink") variables are themselves references. So `list2 = list1` makes two names for one list, and passing an array to a method lets that method change the original. The 2018 ArrayTester FRQ leans on exactly this.

### Primitive types like int and double (Unit 1)

Primitives are the contrast case. An `int` variable holds the actual value, so copying it makes a true independent copy. A reference variable holds an address, so copying it just makes another pointer to the same object.

## On the AP Exam

References are tested constantly even when the word "reference" never appears in the question. MCQs love trace problems where two variables point at the same object, like `ArrayList<String> list3 = list1;` followed by mutations, and ask what each variable "sees" afterward. Another classic stem assigns `student1 = student3;` and prints through both names, or declares a variable without initializing it and asks what happens when you call a method on `null`.

On FRQs, you use references every time you write `new` and store the result, like building a `WordPair` object (2018 Q2) or an `ArrayList<Integer>` of digits (2017 Q1). The 2018 ArrayTester question requires understanding that a 2D array parameter is a reference, so you're reading the caller's actual array. What you must DO: declare reference variables correctly (`String s = new String(...)` or `String s = "..."`), predict aliasing effects, recognize `NullPointerException` situations, and remember that reassigning a reference doesn't destroy the old object's data, it just points your variable somewhere else.

## reference vs primitive variable

A primitive variable (like `int x = 5`) stores the value itself, so `int y = x` makes a fully independent copy. A reference variable (like `Rectangle r`) stores an address, so `Rectangle r2 = r` creates a second name for the same object. Change the object through `r2` and `r` sees it too. With primitives, changes never travel between variables; with references, they do whenever both point at the same object.

## Key Takeaways

- A reference variable holds the memory address of an object, not the object itself (EK 1.12.B.1).
- Assigning one reference variable to another (`list3 = list1`) copies the address, so both variables now point to the same object, and mutations through either one are visible through both.
- A reference can hold `null`, which means it points to no object, and calling any method through a null reference throws a NullPointerException.
- Primitives copy values; references copy addresses. That single difference explains most aliasing and parameter-passing questions on the exam.
- Reassigning a reference to a new object doesn't delete the original object, it just makes your variable point somewhere else.
- Every object in Java (Strings, ArrayLists, custom classes) is accessed through a reference, so this Unit 1 idea shows up in every later unit.

## FAQs

### What is a reference in AP Computer Science A?

A reference is the value a variable of a reference type holds, best thought of as the memory address of an object (EK 1.12.B.1, Topic 1.12). The variable points to the object rather than containing it.

### Does setting two variables equal to each other copy the object in Java?

No. With reference types, `obj2 = obj1` copies only the address, so both variables point to the same single object. If you add an element through `obj1`, `obj2` sees it too. To get an independent copy, you'd have to construct a new object.

### What's the difference between a reference and a primitive in Java?

A primitive variable like `int` or `double` stores its actual value, while a reference variable like `String` or `ArrayList` stores the address of an object in memory. Copying a primitive makes an independent value; copying a reference makes an alias to the same object.

### What happens if I call a method on a null reference?

Java throws a NullPointerException at runtime. A declaration like `Student student2 = null;` means the variable exists but points to no object, so `student2.getName()` crashes. This is a favorite MCQ trap.

### Is the word "reference" actually tested on the AP CSA exam?

Yes, both directly and indirectly. It's named in learning objective 1.12.B, and aliasing trace questions are MCQ staples. Every FRQ also depends on it, since released questions like 2017 Q1 (Digits) and 2018 Q2 (WordPair) require constructing objects and working through references.

## Related Study Guides

- [1.12 Objects: Instances of Classes](/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/reference#resource","name":"Reference — AP Comp Sci A Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/reference","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/reference#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T05:27:19.775Z","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/reference#term","name":"reference","description":"In AP Computer Science A, a reference is the value stored in a variable of a reference type: essentially the memory address of an object, not the object itself (EK 1.12.B.1). Two variables can hold references to the same object, so changing the object through one variable is visible through the other.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/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 a reference in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"A reference is the value a variable of a reference type holds, best thought of as the memory address of an object (EK 1.12.B.1, Topic 1.12). The variable points to the object rather than containing it."}},{"@type":"Question","name":"Does setting two variables equal to each other copy the object in Java?","acceptedAnswer":{"@type":"Answer","text":"No. With reference types, `obj2 = obj1` copies only the address, so both variables point to the same single object. If you add an element through `obj1`, `obj2` sees it too. To get an independent copy, you'd have to construct a new object."}},{"@type":"Question","name":"What's the difference between a reference and a primitive in Java?","acceptedAnswer":{"@type":"Answer","text":"A primitive variable like `int` or `double` stores its actual value, while a reference variable like `String` or `ArrayList` stores the address of an object in memory. Copying a primitive makes an independent value; copying a reference makes an alias to the same object."}},{"@type":"Question","name":"What happens if I call a method on a null reference?","acceptedAnswer":{"@type":"Answer","text":"Java throws a NullPointerException at runtime. A declaration like `Student student2 = null;` means the variable exists but points to no object, so `student2.getName()` crashes. This is a favorite MCQ trap."}},{"@type":"Question","name":"Is the word \"reference\" actually tested on the AP CSA exam?","acceptedAnswer":{"@type":"Answer","text":"Yes, both directly and indirectly. It's named in learning objective 1.12.B, and aliasing trace questions are MCQ staples. Every FRQ also depends on it, since released questions like 2017 Q1 (Digits) and 2018 Q2 (WordPair) require constructing objects and working through references."}}]},{"@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 1","item":"https://fiveable.me/ap-comp-sci-a/unit-1"},{"@type":"ListItem","position":4,"name":"reference"}]}]}
```
