Back to the blog
AP Computer Science A18 min read

AP Computer Science A Review Guide: All 10 Units with Java Tips

A complete AP Computer Science A review guide covering all 10 units of Java, common FRQ patterns, 2D arrays, recursion, inheritance, and the Java syntax gotchas the exam tests every year.

FinalsPrep Team
Written by the tutoring team

AP Computer Science A is the most practical AP exam in the lineup: you learn Java, and the exam tests whether you can read Java and write Java. Every FRQ is a class, a method, or a loop. The patterns are predictable. The syntax is what trips people up.

This guide walks through every unit, the four FRQ patterns that repeat every year, and the Java syntax gotchas that cost the most points. If you can read, write, and trace Java code, you will score well.

What the exam looks like

Exam structure and scoring

  • 3 hours total.
  • Section I: 40 multiple choice in 90 minutes. Worth 50 percent of score.
  • Section II: 4 free response in 90 minutes. Worth 50 percent of score.
  • FRQ #1: methods and control structures (often a class with a method to implement).
  • FRQ #2: a class design (write a class from specification).
  • FRQ #3: array or ArrayList manipulation.
  • FRQ #4: 2D array traversal.
  • A Java Quick Reference is provided (subset of String, Math, ArrayList, etc.). You do not need to memorize method signatures.

Unit 1: Primitive Types

What you need to know

  • Primitives: int, double, boolean (there are others but these three are tested most).
  • Arithmetic: +, -, *, /, %. Precedence follows math rules (PEMDAS).
  • Integer division truncates: 5 / 2 equals 2, not 2.5. To get a decimal, cast at least one operand: (double) 5 / 2 equals 2.5.
  • Modulo (%) gives the remainder: 7 % 3 equals 1. Useful for checking even/odd (n % 2 == 0).
  • Casting: (int) 3.7 equals 3 (truncates). (double) 5 equals 5.0.
  • Variable assignment: int x = 5. Reassignment: x = x + 1 (or x++).

Unit 2: Using Objects

What you need to know

  • Strings are objects. String s = "hello". Create with double quotes or new String().
  • String methods you must know: .length() (returns int), .substring(int), .substring(int, int), .indexOf(String), .equals(String), .compareTo(String).
  • Strings are IMMUTABLE. s.substring(1) returns a NEW string; it does not modify s.
  • String concatenation uses +. "hello" + " world" equals "hello world".
  • Math class (static methods): Math.sqrt(x), Math.pow(base, exp), Math.abs(x), Math.random() (returns double in [0, 1)), Math.min, Math.max.
  • Wrapper classes: Integer (wraps int), Double (wraps double). Used when you need to put primitives in an ArrayList.
  • Autoboxing: int automatically converts to Integer when needed. Unboxing: Integer to int.

Unit 3: Boolean Expressions and if Statements

What you need to know

  • Comparison operators: <, >, <=, >=, ==, !=. Return boolean.
  • Logical operators: && (AND), || (OR), ! (NOT).
  • Short-circuit evaluation: && stops at first false, || stops at first true. Use this for safe checks: if (i < arr.length && arr[i] > 0) — the second condition only runs if the first is true, preventing ArrayIndexOutOfBounds.
  • De Morgan's laws: !(a && b) equals !a || !b. !(a || b) equals !a && !b.
  • if-else-if structure: only first matching branch runs.
  • Compound conditions: if (x > 0 && y > 0) — both must be true.

Unit 4: Iteration

What you need to know

  • while loop: runs as long as condition is true. Easy to create infinite loops if condition never becomes false.
  • for loop: initialization, condition, update. for (int i = 0; i < n; i++).
  • Nested loops: loop inside a loop. O(n squared) time complexity for common cases.
  • Breaking out of loops: return statement, or setting condition to false.
  • Off-by-one errors: should the loop run n times or n-1 times? Tracing through on paper catches these.
  • Loop invariants: what is true at the start of every iteration? This helps debug loops.

Unit 5: Writing Classes

What you need to know

  • Class: blueprint for objects. public class Car { ... }.
  • Instance variables (fields): variables held by each object. private int speed;.
  • Constructor: initializes a new object. Has same name as class, no return type.
  • Methods: functions inside a class. Can access instance variables.
  • this keyword: refers to the current object. Useful for disambiguation: this.speed = speed.
  • Visibility: public (accessible anywhere), private (only inside the class). Encapsulate: make fields private, expose with getters/setters.
  • Static keyword: belongs to the class, not an instance. static int count; shared by all instances. Access with ClassName.count, not instance.count.
public class Book {\n    private String title;\n    private int pages;\n\n    public Book(String t, int p) {\n        title = t;\n        pages = p;\n    }\n\n    public String getTitle() { return title; }\n    public int getPages() { return pages; }\n    public void setPages(int p) { pages = p; }\n}

Unit 6: Array

What you need to know

  • Array: fixed-size, ordered collection of same-type items.
  • Declaration: int[] arr = new int[10]. Or int[] arr = {1, 2, 3}.
  • Access: arr[i]. Indices start at 0 and go to arr.length - 1.
  • Length: arr.length (PROPERTY, no parens). This is different from String.length() (method).
  • Traversal with for loop: for (int i = 0; i < arr.length; i++) { ... arr[i] ... }.
  • Enhanced for loop (for-each): for (int n : arr) { ... n ... }. Good for reading, but you cannot modify arr elements through n.
  • Common operations: find max, find min, count matching, sum, reverse, shift.

Unit 7: ArrayList

What you need to know

  • ArrayList: dynamic (resizable) array of objects. ArrayList<Integer> list = new ArrayList<Integer>().
  • Autoboxing: list.add(5) auto-converts 5 (int) to Integer.
  • Methods: .add(E), .add(int, E), .get(int), .set(int, E), .remove(int), .remove(E), .size().
  • Size is a METHOD: list.size() (with parens). Different from array.length (property). String.length() is a method. Array .length is property. ArrayList .size() is method. This inconsistency is tested every year.
  • Iteration: standard for with .size() and .get(i), or enhanced for.
  • Removing while iterating: iterate BACKWARDS (from size()-1 to 0) to avoid skipping elements when indices shift.
Watch out
Array length is a PROPERTY (arr.length, no parens). ArrayList size is a METHOD (list.size(), with parens). String length is a METHOD (s.length(), with parens). That inconsistency is tested every year. Memorize it.

Unit 8: 2D Array

What you need to know

  • 2D array: array of arrays. int[][] grid = new int[rows][cols].
  • Access: grid[row][col]. First index is row, second is column.
  • Dimensions: grid.length is number of rows. grid[0].length is number of columns (assuming all rows same length).
  • Row-major traversal: outer loop rows, inner loop columns. Most common.
  • Column-major traversal: outer loop columns, inner loop rows. Less common, used for column-specific operations.
  • Common operations: find max in each row/column, count occurrences, check if matrix is symmetric, sum of diagonal.
public static int sumAll(int[][] grid) {\n    int sum = 0;\n    for (int r = 0; r < grid.length; r++) {\n        for (int c = 0; c < grid[r].length; c++) {\n            sum += grid[r][c];\n        }\n    }\n    return sum;\n}

Unit 9: Inheritance

What you need to know

  • Inheritance: a class extends another class, inheriting its public methods and fields. public class Dog extends Animal { ... }.
  • Subclass (child) extends superclass (parent). Subclass inherits non-private methods.
  • super keyword: access superclass constructor or method. super(args) calls parent constructor. super.method() calls parent's version.
  • Method overriding: subclass redefines a method with same signature. @Override annotation helps catch typos.
  • Polymorphism: declare variable as superclass type, assign subclass object. At runtime, the correct (overridden) method runs. Animal a = new Dog(); a.makeSound(); runs Dog's version.
  • Object class: root of all Java classes. Every class inherits toString(), equals(), hashCode() from Object.
  • Abstract classes: cannot be instantiated. Abstract methods must be overridden by subclasses.

Unit 10: Recursion

What you need to know

  • Recursion: a method that calls itself.
  • Two parts: base case (stops recursion, no recursive call) and recursive case (calls itself with a smaller or simpler input).
  • Without a base case: infinite recursion, StackOverflowError.
  • Common recursive problems: factorial, Fibonacci, sum of array, binary search, tree traversal.
  • Tracing recursion: draw the call stack. Each call is a frame, parent waits for child to return.
  • Recursion is often equivalent to iteration but more elegant for naturally recursive problems (trees, divide-and-conquer).
public static int factorial(int n) {\n    if (n <= 1) return 1;      // base case\n    return n * factorial(n - 1); // recursive case\n}\n\npublic static int fibonacci(int n) {\n    if (n <= 1) return n;\n    return fibonacci(n - 1) + fibonacci(n - 2);\n}

The four FRQ patterns that repeat

  1. Methods and control structures: write a method that loops and performs logic. Often involves an ArrayList or array parameter. Practice filter, transform, count methods.
  2. Class design: given a specification, write a class with fields, constructor, and methods. The spec describes what the class should DO; you translate to code.
  3. Array / ArrayList: manipulate a collection. Filter, sum, search, sort, reverse. Know both array and ArrayList syntax cold.
  4. 2D array: traverse a grid. Find max in each row, sum all elements, count occurrences. Nested for loops. Know row vs column indexing.

Java syntax gotchas

  • String comparison: use .equals(), NOT ==. == compares references; .equals compares content.
  • .length vs .length() vs .size(): array is property (no parens), String is method (with parens), ArrayList is method (with parens).
  • Integer division truncates: 5 / 2 = 2. Cast to double for decimal: (double) 5 / 2 = 2.5.
  • ArrayList holds OBJECTS only. ArrayList<Integer>, not ArrayList<int>. Autoboxing handles conversion.
  • When removing from ArrayList while iterating, iterate BACKWARDS to avoid skipping elements.
  • Off-by-one: does the loop include arr.length or stop at arr.length - 1? Hint: use < arr.length, not <=.
  • 2D array: grid.length is rows, grid[0].length is columns. Don't confuse.
  • Overriding requires identical signature: same name, same parameters, same return type.
  • Don't forget to return. If a method has a return type (not void), every path must return.

How to score a 5 on AP CSA

  1. Practice tracing code by hand. The MCQ asks what a method returns. If you cannot trace it on paper, the method is confusing in your head too.
  2. Master the four FRQ patterns. Do at least 4-6 timed FRQs from past exams. The patterns repeat every year.
  3. Learn the Java Quick Reference. It tells you what methods are available. If you forget a method signature, check it.
  4. Know the syntax gotchas (especially .length vs .length() vs .size()). These are GUARANTEED to appear.
  5. Code is graded on correctness AND style. Use clear variable names (total, sum, count, not x, y, z). Indent consistently.

Common mistakes

  • Using == instead of .equals() for String comparison. 'abc' == 'abc' is sometimes true in Java for literal strings, but you should ALWAYS use .equals() for strings.
  • Off-by-one errors in loops. Test your code mentally with edge cases (empty array, array of 1, boundary values).
  • Modifying an ArrayList while iterating forward: elements shift, you skip items. Iterate backward or use Iterator.remove().
  • Forgetting to return from a non-void method. Every code path must return a value.
  • Using int when you need double (or vice versa). Division and assignment rules differ.
  • Forgetting @Override (not required, but catches typos). Without it, a typo creates a new method rather than overriding.
  • Using instance variable name when constructor parameter shadows it. Use this.variable = variable to disambiguate.
  • Confusing public and private. Private can only be accessed within the class. Public is accessible anywhere.
Note
FinalsPrep can step through any Java method you paste in and show what each variable holds at each line. Catches off-by-one and missing returns before the exam does. Free tier covers the course.

AP CSA rewards clean, readable code. Write like someone has to grade it in 30 seconds, because someone does.

Practice this with the tutor
Want to work through a AP Computer Science A problem using the concepts in this guide? The tutor already knows the CED.
Open tutor with AP Computer Science A context →

Discussion

Ask a question, share what clicked, or help out another student.

Join the discussion

Sign in to leave a comment, reply to other students, and upvote what helped you. Free account, same one that runs the tutor.

Loading comments…
Try it while it's fresh

Stuck on a AP Computer Science A problem? Walk through it with the tutor.

Paste a problem, snap a picture of your homework, or ask about any concept from this guide. The FinalsPrep tutor already knows the AP Computer Science A CED. Free tier. No card required.

Keep reading