Putting an entire class together.
Fields, constructor, accessors, mutators, behavior methods — every AP class FRQ assembles these pieces in the same order.
A complete class follows a standard order: private instance variables, constructors, accessors, mutators, and behavior methods. Following this template makes your code easy to read and matches what AP graders expect.
The pieces work together: the constructor initializes the fields; accessors expose them; mutators change them safely; behavior methods do useful work using the state.
On the AP exam, class design FRQs ask you to write all these pieces from a written specification.
Standard class structure, in order.
Five sections; same order every time.
Complete Book class
public class Book {
// 1. Instance variables
private String title;
private String author;
private int pagesRead;
private int totalPages;
// 2. Constructor
public Book(String title, String author, int totalPages) {
this.title = title;
this.author = author;
this.totalPages = totalPages;
this.pagesRead = 0;
}
// 3. Accessors
public String getTitle() { return title; }
public String getAuthor() { return author; }
public int getPagesRead() { return pagesRead; }
public int getTotalPages() { return totalPages; }
// 4. Mutator
public void readPages(int n) {
pagesRead = pagesRead + n;
if (pagesRead > totalPages) pagesRead = totalPages;
}
// 5. Behavior
public boolean isFinished() {
return pagesRead == totalPages;
}
public double percentComplete() {
return 100.0 * pagesRead / totalPages;
}
}
Constructor initializes everything
Every field gets a starting value — either from a parameter or a sensible default like 0 or null.
Class-design vocabulary.
Standard structure terms.
- Constructor — special method that initializes a new object.
- Field / instance variable — state stored in each object.
- Accessor — returns a field.
- Mutator — changes a field.
- Behavior method — does something using state.
- Default value — sensible initial value (0, null, "").
How complete-class FRQs are scored.
Structure and correctness both matter.
- Private fields. Standard rubric point.
- Constructor sets every field. Use parameters or defaults.
- Match the spec's signatures. Method names, params, returns.
- Use
thisas needed. Especially when params shadow fields.
Trace a Book through reading.
Fields update; behavior reflects state.
Setup. Book b = new Book("Dune", "Herbert", 600); — pagesRead = 0.
- b.readPages(200) → pagesRead = 200.
- b.percentComplete() → 100.0 * 200 / 600 = 33.33...
- b.readPages(500) → pagesRead = 700, but capped to 600.
- b.isFinished() → true.
- b.percentComplete() → 100.0.
Complete-class pitfalls.
Missing constructor pieces or signature drift.
- Constructor doesn't init every field. Some default to 0/null but that may be wrong.
- Public fields. Loses encapsulation.
- Wrong method names or types. Spec must match exactly.
- Forgetting
this. Causes self-assignment with shadowed params.
Class skeleton order.
Five sections.
Complete Class Reference
AP Quick Reference| Section | Content | Modifiers |
|---|---|---|
| 1. Fields | Instance variables | private |
| 2. Constructor | Init fields | public |
| 3. Accessors | Return fields | public |
| 4. Mutators | Change fields | public |
| 5. Behavior | Use state | public |
How to master complete-class design.
Write the skeleton first; fill in bodies second.
- MCQ Practice — verify all five sections appear in the right order.
- Java Lab — write Book, Movie, Course classes from prose specs.
- FRQ Practice — outline private fields, constructor, accessors, mutators, behaviors before filling in details.
Practice — attempt these now.
AP-style assessments aligned to this lesson. Time them.
AP CSA Unit 13 Topic 02 Complete Class Design FRQ Practice
AP-style topic practice assessment