---
title: "Private — AP Computer Science A Definition & Exam Guide"
description: "Private is the Java access modifier that locks instance variables and methods inside their own class. It powers encapsulation and shows up in every AP CSA FRQ."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/private"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 3"
---

# Private — AP Computer Science A Definition & Exam Guide

## Definition

In AP Computer Science A, private is a Java access modifier that restricts a variable or method so only code inside the same class can use it; the AP CSA course convention is that all instance variables are declared private to enforce encapsulation.

## What It Is

**Private** is one of Java's [access modifiers](/ap-comp-sci-a/key-terms/access-modifiers "fv-autolink"), the keywords that control who is allowed to touch a [class](/ap-comp-sci-a/unit-3/abstraction-and-program-design/study-guide/o9VgVeIpKRYZ7N7rXfUz "fv-autolink") member. When you mark a variable or method `private`, only code written inside that same class can read it, change it, or call it.

Think of a class as a house. Public methods are the front door, the official way in. Private instance variables are the stuff inside the house. Visitors don't get to rummage through your drawers; they knock on the door and ask. That "ask through a method" [pattern](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z "fv-autolink") is **encapsulation**, and it's the whole reason private exists. In AP CSA, the convention is strict: instance variables are *always* private, and the outside world interacts with them only through public methods like getters, setters, and constructors.

## Why It Matters

Private is the mechanism behind encapsulation, one of the central object-oriented design ideas in AP CSA's class-writing units. The course convention (and the FRQ scoring expectation) is that [instance variables](/ap-comp-sci-a/key-terms/instance-variables "fv-autolink") are declared private and accessed through [public](/ap-comp-sci-a/key-terms/public "fv-autolink") methods...)` instead of assigning inherited fields directly. If you've ever wondered why `Car` can't just write `make = "Toyota";` when `make` lives in `Vehicle`, the answer is one word: private.

## Connections

### Encapsulation (Class Writing)

Private is how you actually implement encapsulation in Java. Encapsulation is the design principle (hide the data, expose behavior), and the private keyword is the tool that does the hiding.

### Public / Access Modifiers (Class Writing)

Private and public are two settings on the same dial. AP CSA's rule of thumb is simple: instance variables get private, and the methods other classes need to call get public.

### Mutable Objects (References)

Watch the leak. If a getter returns a [reference](/ap-comp-sci-a/key-terms/reference "fv-autolink") to a private mutable object (like an ArrayList), outside code can change its contents anyway. Private protects the variable, not necessarily the object it points to.

## On the AP Exam

On the FRQs, private is everywhere even when the question isn't "about" it. Released questions like 2017's Digits and Phrase classes hand you private instance variables, and you're expected to work with them through methods. When a class-design FRQ asks you to write a full class (like 2017 Q2's StudyPractice implementation), declare your instance variables private. Writing them public violates the course's encapsulation convention and can cost you points.

## Private vs Public

Public means any class anywhere can access the member; private means only code inside the declaring class can. They're opposite ends of Java's visibility settings. Mixing this up on a class-design FRQ (public instance variables) is one of the most common self-inflicted point losses.

## Key Takeaways

- Private restricts access to a variable or method so only code inside the same class can use it.
- In AP CSA, instance variables are always declared private, and other classes reach them through public getter, setter, and constructor methods.
- ..) to initialize them.
- Private is the keyword that implements encapsulation; encapsulation is the design idea, private is the enforcement.
- On class-design FRQs, declaring instance variables public instead of private violates the expected convention and can lose points.

## FAQs

### What does private mean in Java for AP Computer Science A?

Private is an [access modifier](/ap-comp-sci-a/key-terms/access-modifier "fv-autolink") that limits a variable or method to the class it's declared in. In AP CSA, all instance variables follow this convention.

### What's the difference between private and public in Java?

Public members are accessible from any class; private members are accessible only within their own class. The AP CSA pattern is private instance variables paired with public methods, so the class controls exactly how its data gets used.

### Do I have to make instance variables private on the AP exam?

Yes. When an FRQ asks you to design or complete a class, declare instance variables private. It's the encapsulation convention the scoring guidelines expect, and public instance variables can cost you the point for declaring fields correctly.

### Does private mean the data can never be changed?

No. Private controls who can access the variable, not whether it can change. The class's own methods can still modify private data, and a public setter can let outsiders change it indirectly. If you want a value that never changes, that's the [final keyword](/ap-comp-sci-a/key-terms/final-keyword "fv-autolink"), a different tool entirely.

## Related Study Guides

- [3.4 Constructors](/ap-comp-sci-a/unit-3/constructors/study-guide/3Ez6zzak2wRwMrTj2ZQk)
- [3.3 Anatomy of a Class](/ap-comp-sci-a/unit-3/anatomy-of-a-class/study-guide/DcGY5KOyK98H9Fn2w8jh)
- [4.10 Developing Algorithms Using ArrayLists](/ap-comp-sci-a/unit-4/developing-algorithms-using-arraylists/study-guide/MKbteieYvLOpWIwfqiND)
- [3.5 Writing Methods](/ap-comp-sci-a/unit-3/writing-methods/study-guide/rtuMpRFmidkpYTzvDndS)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/private#resource","name":"Private — AP Computer Science A Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/private","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/private#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"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/private#term","name":"Private","description":"In AP Computer Science A, private is a Java access modifier that restricts a variable or method so only code inside the same class can use it; the AP CSA course convention is that all instance variables are declared private to enforce encapsulation.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/private","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 does private mean in Java for AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"Private is an [access modifier](/ap-comp-sci-a/key-terms/access-modifier \"fv-autolink\") that limits a variable or method to the class it's declared in. In AP CSA, all instance variables follow this convention."}},{"@type":"Question","name":"What's the difference between private and public in Java?","acceptedAnswer":{"@type":"Answer","text":"Public members are accessible from any class; private members are accessible only within their own class. The AP CSA pattern is private instance variables paired with public methods, so the class controls exactly how its data gets used."}},{"@type":"Question","name":"Do I have to make instance variables private on the AP exam?","acceptedAnswer":{"@type":"Answer","text":"Yes. When an FRQ asks you to design or complete a class, declare instance variables private. It's the encapsulation convention the scoring guidelines expect, and public instance variables can cost you the point for declaring fields correctly."}},{"@type":"Question","name":"Does private mean the data can never be changed?","acceptedAnswer":{"@type":"Answer","text":"No. Private controls who can access the variable, not whether it can change. The class's own methods can still modify private data, and a public setter can let outsiders change it indirectly. If you want a value that never changes, that's the [final keyword](/ap-comp-sci-a/key-terms/final-keyword \"fv-autolink\"), a different tool entirely."}}]},{"@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":"Private"}]}]}
```
