AP Computer Science A is Java taught through object-oriented design, and students who think in terms of objects, inheritance, and abstraction find it far easier than those memorising syntax in isolation. The exam only tests the subset of Java in the AP Quick Reference, so master that plus the four free-response types (methods and control structures, class writing, array/ArrayList/2D array, and inheritance), write clean indented code so graders can award partial credit, and avoid the classic traps — above all using == instead of .equals() to compare Strings.
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
Frequently asked questions
What topics are covered in AP Computer Science A?
AP Computer Science A covers Java programming with emphasis on object-oriented design. The main content areas are: Primitive Types and Classes (int, double, boolean, String class basics), Using Objects (methods, string methods, Math class, wrapper classes, reference vs primitive types), Boolean Expressions and if Statements, Iteration (while and for loops), Writing Classes (constructors, instance variables, methods, encapsulation, static vs instance), Array (1D arrays, traversal, common algorithms), ArrayList (ArrayList class, methods, traversal, sorting and searching), 2D Array (creation, traversal algorithms), Inheritance (extends, super, polymorphism, abstract classes, interfaces), and Recursion (tracing recursive methods, writing simple recursive methods). The exam uses a subset of Java — the AP Quick Reference lists every method and class you need, and nothing outside that list will be tested.
How is the AP Computer Science A exam structured?
The AP Computer Science A exam has two sections. Section 1 (Multiple Choice, 90 minutes): 40 questions covering all content areas — reading code, tracing execution, identifying errors, and understanding OOP concepts. Section 2 (Free Response, 90 minutes): 4 questions, each targeting a different type of programming task. The four FRQ types are: (1) Methods and Control Structures (write or modify methods), (2) Class writing (write a complete class with specified behaviour), (3) Array/ArrayList/2D Array (traverse and manipulate array structures), (4) Writing code in the context of an existing class hierarchy. Each FRQ is worth 9 points. Multiple choice and free response each count for 50% of the exam score.
What Java syntax is most important for AP Computer Science A?
The most exam-critical Java syntax: variable declaration and assignment (int x = 5; double y = 3.14;), boolean operators (&& for AND, || for OR, ! for NOT), String comparisons (always use .equals(), never == for String content), for loops (especially traversal patterns: for(int i = 0; i < arr.length; i++) and enhanced for-each: for(int val : arr)), ArrayList methods (add, get, set, remove, size), array creation (int[] arr = new int[10]; or initializer: int[] arr = {1, 2, 3};), 2D array traversal (nested for loops), object creation (ClassName obj = new ClassName(args)), calling methods on objects (obj.method()), inheritance (extends keyword, super() constructor call, @Override annotation), and casting (double d = (double) intVal;).
How do I approach the AP CS A free-response questions?
For each FRQ: (1) Read the entire problem carefully — the class context, all given code, and all parts of the question; (2) Identify which content area it targets (array traversal, class writing, inheritance, recursion); (3) For partial credit, write correct code for the parts you know even if you cannot complete everything; (4) Write clean, properly indented Java — graders award partial credit only if they can identify your intent; (5) If you cannot remember an exact method name, use a reasonable name and note 'this method returns...' — you may receive credit; (6) Never leave a blank answer — write pseudocode or comments explaining your approach, which may earn some partial credit. The graders use holistic scoring and reward evidence of understanding even in imperfect code.
What are the most common mistakes in AP Computer Science A?
The most common exam mistakes: (1) Using == to compare String values instead of .equals() — this tests reference equality, not content equality; (2) Off-by-one errors in array traversal — arr[arr.length] causes an ArrayIndexOutOfBoundsException, the valid range is 0 to arr.length-1; (3) Failing to understand that ArrayList.remove(int index) takes an index while ArrayList.remove(Object o) removes the first occurrence of the object — ambiguous calls with integer types default to remove(int index); (4) Confusing instance and static methods — static methods belong to the class and cannot access instance variables without an object; (5) Not calling super() in a subclass constructor when the superclass has a constructor with parameters; (6) Modifying an ArrayList while iterating with a for-each loop — use index-based traversal for removal.
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.
More on US Education: AP, SAT & University