warpread
← Blog

AP Computer Science A Study Guide: Java, OOP, and the Free-Response Questions

9 min readBy warpread.app

AP Computer Science A teaches Java programming through the lens of object-oriented design — the paradigm that organises code around objects that combine data (instance variables) and behaviour (methods). Students who learn to think in terms of objects, inheritance hierarchies, and abstraction find the exam far more manageable than those who try to memorise individual syntax rules without the underlying OOP framework.

The exam tests Java specifically but within a well-defined subset. The AP Java Quick Reference lists every class, method, and interface that may appear on the exam — anything outside this list will not be tested. Download it from the College Board website and keep it visible during practice.

Java fundamentals: the building blocks

Primitive types: int (integer, 32-bit), double (floating-point, 64-bit), boolean (true/false). These are stored by value. Arithmetic: integer division truncates (7/2 = 3, not 3.5); use double division (7.0/2 = 3.5). The modulo operator % gives the remainder (17 % 5 = 2 — useful for "is this divisible by n?" questions).

Reference types: All objects, including String and arrays, are reference types — variables hold a reference (memory address) to the object, not the object itself. This is why == on Strings tests whether they are the same object, not whether they contain the same text. Always use .equals() for String content comparison.

String methods (memorise from the Quick Reference): length(), substring(from, to), indexOf(str), equals(str), compareTo(str) (returns negative if lexicographically before, 0 if equal, positive if after). String concatenation: "Hello" + " World" = "Hello World". Strings are immutable — methods return new Strings, they do not modify the original.

Math class (memorise these): Math.abs(x), Math.pow(x, y), Math.sqrt(x), Math.random() (returns double in [0.0, 1.0)).

Control flow: loops and conditionals

if-else chains: Order matters — once a condition is true, subsequent else-if conditions are not checked.

while loop: Use when the number of iterations is unknown at the start. Classic while pattern: process elements until a sentinel value is found.

for loop: Use when you know the number of iterations. Three parts: initialisation (int i = 0), condition (i < n), update (i++). Enhanced for-each loop (for(Type var : collection)) — simpler for full traversal, but you cannot modify the collection or access the index.

Common iteration patterns: Finding the maximum/minimum in an array, accumulating a sum, counting elements that satisfy a condition, and searching for a target value. Know each pattern as a template.

Object-oriented programming: classes and inheritance

Class structure: Instance variables (data that each object has separately), constructors (initialise the object), methods (actions the object can perform). Encapsulation means instance variables should typically be private, accessed through public getter and setter methods.

Static vs instance: Static methods and variables belong to the class itself — they exist even without any objects created, and they are accessed as ClassName.method(). Instance methods and variables belong to each individual object.

Inheritance: class Dog extends Animal means Dog inherits all public and protected methods and instance variables from Animal. The Dog constructor must call super() (Animal's constructor) as its first statement if Animal has a non-default constructor. Override methods from the superclass using @Override annotation. The Liskov Substitution Principle: an object of type Dog can be used wherever an Animal is expected.

Polymorphism: At runtime, the actual type of the object determines which method is called, not the declared type of the variable. If Animal has a speak() method and Dog overrides it, then Animal a = new Dog(); a.speak(); calls Dog's speak() method.

Abstract classes and interfaces (AP Quick Reference): Abstract methods have no body — subclasses must override them. An interface specifies a contract of methods that implementing classes must provide.

Arrays and ArrayLists

1D arrays: int[] arr = new int[5]; creates an array of five ints, all initialised to 0. Traverse: for(int i = 0; i < arr.length; i++). Never access arr[arr.length] — valid indices are 0 to arr.length-1.

ArrayList: ArrayList<Integer> list = new ArrayList<>(); Key methods: add(element), add(index, element), get(index), set(index, element), remove(index), size(), contains(element). ArrayList is resizable; arrays are fixed-size. For removing elements during traversal, iterate backwards or use an explicit index loop, not for-each.

2D arrays: int[][] grid = new int[rows][cols]; Traverse with nested loops: outer loop for rows (i from 0 to grid.length), inner loop for columns (j from 0 to grid[i].length). Common algorithms: row sum, column sum, finding the maximum in a row.

Recursion

The three questions for any recursive method: (1) What is the base case — when does the recursion stop? (2) What does the recursive call do — what smaller version of the problem does it solve? (3) How does the recursive call contribute to the original problem's solution?

Trace recursion by hand: For small inputs, trace the call stack step by step. Write each call frame and the value it returns. This is what the exam tests — the ability to read a recursive method and determine its output.

Common patterns: Factorial (n! = n × (n-1)!), Fibonacci, traversing a linked structure, binary search implemented recursively, power calculation (x^n = x × x^(n-1)).

Free-response strategy

Spend the first 5 minutes planning all four FRQs — read every part of every question before writing any code. Then prioritise: attempt every part of every question. Partial credit is generous, and a mostly-correct attempt at every question outscores a perfect first two questions with blanks in the last two.

Writing readable code earns points: Proper indentation, meaningful variable names, and clear method calls help graders identify correct intent even in otherwise imperfect solutions.

Use the Spaced Repetition Flashcard Tool for Java syntax rules, especially the common mistakes (String comparison, ArrayList removal, off-by-one in arrays). The Pomodoro Timer helps structure coding practice sessions — 25 minutes of focused FRQ practice, then 5 minutes reviewing the AP Quick Reference. For the broader context of algorithmic thinking, see the A Level Computer Science study guide.

Topics

AP Computer Science A study guideAP CS A reviewAP Computer Science A JavaAP CS A free responseAP Computer Science A OOPAP Computer Science A exam prepAP CS A tipsAP Computer Science A score 5

Prepare for AP exams and college coursework

Build AP flashcard decks with the Spaced Repetition Flashcard Tool, use the Cornell Notes Tool for content-heavy AP subjects, and the Pomodoro Timer to structure daily study sessions.