An access modifier is a Java keyword (public or private on the AP CSA exam) placed before a class, instance variable, constructor, or method that controls which parts of a program can access it; private restricts access to inside the class, while public allows access from anywhere.
An access modifier is the keyword at the front of a declaration that answers one question. Who is allowed to touch this thing? In Java you'll see public, private, and protected, but AP Comp Sci A only tests public and private. A private member can only be used by code inside its own class. A public member can be used from anywhere in the program.
Think of a class like a vending machine. The buttons and the coin slot are public because that's the interface everyone is supposed to use. The wiring and the money box inside are private because letting random code reach in and change them directly would break everything. That design idea is called encapsulation, and access modifiers are how Java enforces it. One big catch you need to memorize: access modifiers go on classes, instance variables, constructors, and methods. They do NOT go on local variables declared inside a method, because a local variable's reach is already limited by its scope.
Access modifiers live at the heart of Unit 5 (Writing Classes), where the CED's data encapsulation standard expects instance variables to be declared private and the methods that other code calls to be declared public. They show up again in Unit 9 (Inheritance), since a subclass cannot directly access the private instance variables it inherits and has to go through public methods instead. This is also FRQ gold. The class-design free response expects you to write private instance variables with public constructors and methods, and using the wrong modifier is a classic way to lose points on otherwise correct code.
Keep studying AP Computer Science A Unit 3
private (Unit 5)
The default choice for instance variables in AP-style class design. Marking data private forces all changes to flow through methods you control, which is the whole point of encapsulation.
public (Unit 5)
The modifier for the parts of a class you want the outside world to use, like constructors, getters, setters, and other methods. Public members form the class's interface, the buttons on the vending machine.
Method header (Unit 5)
The access modifier is literally the first word of a method header, before the return type and method name. In public int getScore(), the public is the access modifier, int is the return type. Knowing which word does which job keeps you from misreading code segments on the MCQ.
Overriding a method (Unit 9)
When a subclass overrides a superclass method, it rewrites the method body, but it still can't see the superclass's private instance variables. That's why overridden methods often call public getters or super methods to reach the data they need.
Multiple-choice questions love testing the local-variable trap. You'll see code like private String tempName = n.trim(); declared inside a constructor and be asked to find the error, and the answer is that local variables cannot have access modifiers. Other MCQs check whether you know that code outside a class can't directly access a private instance variable. On the free response, the class-design question expects you to write the class yourself, and the standard pattern is private instance variables, a public constructor, and public methods. Writing public instance variables or forgetting the modifiers entirely is an easy way to bleed points, so make private data plus public methods your default muscle memory.
Access modifiers and scope both limit where you can use something, but they're different mechanisms. Scope is about WHERE a variable exists. A local variable declared inside a method only exists between its declaration and the end of that block, no keyword needed. Access modifiers are about WHO can reach a class member that exists for the whole object's lifetime. That's also why local variables can't take public or private. Scope already handles them, so an access modifier there is a compile-time error.
An access modifier is a keyword that controls which code can access a class, instance variable, constructor, or method, and AP CSA only tests public and private.
Private members can only be accessed by code inside the same class, while public members can be accessed from anywhere in the program.
The AP-expected design pattern is private instance variables with public constructors and methods, which is how Java enforces encapsulation.
Local variables declared inside a method or constructor can never have an access modifier, and adding one causes a compile-time error.
A subclass does not get direct access to the private instance variables it inherits, so it must use public methods like getters to reach that data.
In a method header like public int getScore(), the access modifier comes first, before the return type.
An access modifier is a Java keyword like public or private that controls which parts of a program can use a class, instance variable, constructor, or method. Private limits access to inside the class itself, and public allows access from anywhere.
No. Local variables declared inside a method or constructor cannot have access modifiers, and writing something like private String temp inside a constructor is a compile-time error. Their visibility is already controlled by scope, not access modifiers.
No. Java has protected, but the AP CSA exam only covers public and private. If you see protected in practice materials, it's beyond what the exam will ask you to write or interpret.
Scope determines where a variable exists at all, like a local variable that disappears when its method ends. An access modifier determines which outside code can reach a member of a class that exists as long as the object does. They solve different problems, which is why local variables don't take access modifiers.
Declaring instance variables private enforces encapsulation, meaning other classes can only change the data through public methods the class provides. The class-design FRQ expects private instance variables and public methods, so using public instance variables can cost you points.