---
title: "Reference Type — AP Computer Science A Definition"
description: "A reference type variable stores a memory address pointing to an object, not the value itself. Core to AP CSA objects, the new keyword, null, and aliasing."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/reference-type"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 1"
---

# Reference Type — AP Computer Science A Definition

## Definition

In AP Computer Science A, a reference type is a data type whose variables store the memory address of an object rather than the object's actual data, so two variables can point to the same object and a change through one is visible through the other.

## What It Is

A reference type is any non-primitive type in Java, which means classes like `String`, `Scanner`, [arrays](/ap-comp-sci-a/unit-4/array-creation-and-access/study-guide/umTe6NA38OqZOhMZjFWi "fv-autolink"), and any class you write yourself. When you declare `String name;`, the variable `name` doesn't hold the text itself. It holds a memory address that points to a `String` [object](/ap-comp-sci-a/key-terms/object "fv-autolink") living somewhere in memory (or it holds `null` if no object has been assigned yet).

Here's the mental model that makes everything click: a reference variable is a remote control, not the TV. You can have two remotes (`Dog a` and `Dog b = a;`) controlling the same TV. Press a button on either one and the same TV changes. That sharing behavior is called **aliasing**, and it's the reason passing an object to a method lets the method modify the original object, while passing an `int` never does. The actual object only comes into existence when you use the `new` keyword to call a [constructor](/ap-comp-sci-a/unit-1/creating-and-storing-objects/study-guide/rUOTKl6Ih5noXJ0GtxJF "fv-autolink").

## Why It Matters

Reference types show up the moment AP CSA introduces objects, right after [primitive types](/ap-comp-sci-a/key-terms/primitive-types "fv-autolink") in the early units, and the distinction never goes away. Every later topic quietly depends on it. Why does `==` compare addresses for objects but values for `int`s? Why does modifying an array inside a [method](/ap-comp-sci-a/unit-3/abstraction-and-program-design/study-guide/o9VgVeIpKRYZ7N7rXfUz "fv-autolink") change the caller's array? Why does calling a method on a `null` reference crash with a `NullPointerException`? All three answers are "because it's a reference type." The CED expects you to know that object variables hold references, that uninitialized references default to `null`, and that copying a reference does not copy the object. If you don't internalize this early, aliasing bugs in array and ArrayList questions will eat you alive later.

## Connections

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

The object is the actual thing in memory; the [reference variable](/ap-comp-sci-a/key-terms/reference-variable "fv-autolink") is just the address that points to it. One object can have many references, and an object with zero references becomes unreachable garbage.

### [New Keyword (Units 1-2)](/ap-comp-sci-a/key-terms/new-keyword)

Declaring a reference variable creates the remote, but `new` builds the TV. The `new` keyword calls a constructor, allocates the object in memory, and hands back the [reference](/ap-comp-sci-a/key-terms/reference "fv-autolink") you store in your variable.

### [null (Units 1-2)](/ap-comp-sci-a/key-terms/null)

`null` is the special value a reference holds when it points to no object at all. Calling any method on a `null` reference throws a `NullPointerException`, one of the most-tested runtime errors in AP CSA.

### Abstraction (Units 1-2)

References let you work with an object through its methods without caring where it lives in memory or how its data is stored. That separation between using an object and knowing its internals is abstraction in action.

## On the AP Exam

Reference types are mostly tested through multiple-choice questions that probe whether you know what a reference variable actually stores. Common stems ask what a reference variable holds when no object is assigned (answer: `null`), how to correctly declare a variable that stores a reference to a `String`, and which statements about `null` are true. The trickier MCQs trace aliasing: two variables point to the same object, the code mutates through one, and you have to predict what the other one "sees." Watch for `==` versus `.equals()` traps, since `==` on references compares addresses, not contents. No released FRQ asks you to define "reference type," but every FRQ that passes objects or arrays into methods assumes you understand that the method receives a copy of the reference, so mutations to the object stick.

## Reference Type vs Primitive Type

A primitive variable (`int`, `double`, `boolean`) stores the value itself, directly in the variable. A reference variable stores an address that points to an object. Copy a primitive and you get an independent value; copy a reference and you get a second remote control for the same object. This is why `int x = y;` can never cause one variable to affect another, but `Dog a = b;` absolutely can.

## Key Takeaways

- A reference type variable stores the memory address of an object, not the object's data itself.
- All non-primitive types in Java are reference types, including String, arrays, ArrayList, and every class you write.
- Assigning one reference variable to another copies the address, so both variables point to the same object (aliasing).
- A reference variable that hasn't been assigned an object holds null, and calling a method on it throws a NullPointerException.
- Using == on reference types compares addresses, so use .equals() to compare object contents like Strings.
- When you pass an object to a method, the method gets a copy of the reference, which is why it can modify the original object.

## FAQs

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

A reference type is a [data type](/ap-comp-sci-a/key-terms/data-type "fv-autolink") whose variables store the memory address of an object instead of the value itself. All class types in Java, including String, arrays, and your own classes, are reference types.

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

Primitives like int and double store their value directly in the variable; reference types store an address pointing to an object. Copying a primitive makes an independent copy, while copying a reference makes two variables that share one object.

### Does copying a reference variable copy the object?

No. Writing `Dog b = a;` copies only the address, so a and b point to the same Dog object. To get a separate object you'd need to construct a new one with the new keyword.

### What does a reference variable store before it's assigned an object?

It holds null, meaning it points to no object. If you call a method through that null reference, your program crashes with a NullPointerException, which is a frequent MCQ answer choice.

### Is String a reference type or a primitive in Java?

String is a reference type, since it's a class, not a primitive. That's why == on two Strings compares addresses and you should use .equals() to compare their actual text on the AP exam.

## Related Study Guides

- [1.12 Objects: Instances of Classes](/ap-comp-sci-a/unit-1/objects-instances-of-classes/study-guide/EcpFHGcIKu6385hMohLe)
- [1.13 Creating and Storing Objects](/ap-comp-sci-a/unit-1/creating-and-storing-objects/study-guide/rUOTKl6Ih5noXJ0GtxJF)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/reference-type#resource","name":"Reference Type — AP Computer Science A Definition","url":"https://fiveable.me/ap-comp-sci-a/key-terms/reference-type","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/reference-type#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-12T22:52:43.524Z","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-type#term","name":"Reference Type","description":"In AP Computer Science A, a reference type is a data type whose variables store the memory address of an object rather than the object's actual data, so two variables can point to the same object and a change through one is visible through the other.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/reference-type","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 type in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"A reference type is a [data type](/ap-comp-sci-a/key-terms/data-type \"fv-autolink\") whose variables store the memory address of an object instead of the value itself. All class types in Java, including String, arrays, and your own classes, are reference types."}},{"@type":"Question","name":"What's the difference between a reference type and a primitive type?","acceptedAnswer":{"@type":"Answer","text":"Primitives like int and double store their value directly in the variable; reference types store an address pointing to an object. Copying a primitive makes an independent copy, while copying a reference makes two variables that share one object."}},{"@type":"Question","name":"Does copying a reference variable copy the object?","acceptedAnswer":{"@type":"Answer","text":"No. Writing `Dog b = a;` copies only the address, so a and b point to the same Dog object. To get a separate object you'd need to construct a new one with the new keyword."}},{"@type":"Question","name":"What does a reference variable store before it's assigned an object?","acceptedAnswer":{"@type":"Answer","text":"It holds null, meaning it points to no object. If you call a method through that null reference, your program crashes with a NullPointerException, which is a frequent MCQ answer choice."}},{"@type":"Question","name":"Is String a reference type or a primitive in Java?","acceptedAnswer":{"@type":"Answer","text":"String is a reference type, since it's a class, not a primitive. That's why == on two Strings compares addresses and you should use .equals() to compare their actual text on the AP exam."}}]},{"@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 Type"}]}]}
```
