What it covers: Abstraction and program design, encapsulation, constructors, instance variables, accessor/mutator methods, parameter passing, static members, scope, and the this keyword.
Exam weight: About 10–18% of the multiple-choice section, and the focus of the Class Design free-response question.
The big question: How do you design and build your own classes in Java?
Computational thinking practices: Design Code, Develop Code, Analyze Code, Document Code, and Use Computers Responsibly.
Key topics at a glance
Anatomy of a Class
A class has instance variables (state), a constructor (initialization), and methods (behavior). In this course classes are public.
Encapsulation
Make instance variables private and expose behavior through public methods, so outside classes can’t change state directly.
Constructors
Same name as the class, no return type. Initializes instance variables. A missing constructor gives a default that sets fields to 0/0.0/false/null.
Accessor vs. Mutator
Accessor (getter): returns a value, changes nothing. Mutator (setter): changes an instance variable, usually returns void.
Parameters & Return
A parameter is named in the header; an argument is passed at the call. Primitives are passed by value (a copy). The return type sets what comes back.
static (Class) Members
static variables/methods belong to the class, shared by all objects (one copy). Call with ClassName.member; static methods can’t use this.
Scope
Local variables live only inside their method/block. Instance variables are visible in all the object’s non-static methods.
this Keyword
Refers to the current object. Use this.field = field; to tell an instance variable apart from a same-named parameter.
The key terms and rules you must know
Class — a template defining state and behavior.
Encapsulation — private data + public methods.
public / private — access from anywhere / only within the class.
Instance variable — per-object state (usually private).
Constructor — initializes an object; no return type.
Accessor (getter) — returns a value, no change.
Mutator (setter) — changes state, usually void.
Parameter vs. argument — header name vs. passed value.
Pass by value — primitives are copied into parameters.
static — class-level, one shared copy.
Scope — local vs. instance visibility.
this — the current object.
Key themes to remember
A class bundles state and behavior. Instance variables plus methods.
Encapsulation protects data. private fields, public methods.
Constructors set up objects. Same name, no return type.
static belongs to the class. Instance members belong to the object.
this disambiguates names. this.field vs. a same-named parameter.
Common exam traps
Constructors have no return type — not even void.
private blocks outside access — you can’t read obj.field from another class.
Mutators return void; accessors return a value. Don’t swap them.
Primitives are passed by value — a method can’t change the caller’s int.
static methods can’t use this or instance variables directly.
Use this.field = field when a parameter shadows an instance variable.
Inheritance is out of scope for AP CSA — don’t use extends/super.