Math & Computer Science CS A

AP Computer Science A

Object-oriented programming and problem-solving in Java.

Study guide last reviewed September 25, 2026 · see what changed

Exam Format

Format reflects the current published structure — always confirm against AP Central before test day, since formats occasionally change.

SectionDetailsTimeWeight
Section I – Multiple Choice40 questions1 hr 30 min50%
Section II – Free Response4 questions (methods/control structures, classes, arrays/ArrayLists, 2-D array)1 hr 30 min50%

Frequently Asked Questions

Straight answers about the AP Computer Science A exam — format, credit, dates, and this site.

What's the format of the AP Computer Science A exam?

Section I – Multiple Choice: 40 questions (1 hr 30 min, 50% of the total score); Section II – Free Response: 4 questions (methods/control structures, classes, arrays/ArrayLists, 2-D array) (1 hr 30 min, 50% of the total score). See the Exam Format tab above for the full breakdown, and always double-check the current year's format on AP Central before test day.

Is the AP Computer Science A exam multiple-choice, written response, or portfolio-based?

It's multiple-choice questions and written free-response or essay questions.

What score do I need on AP Computer Science A for college credit?

It depends entirely on the college — most award credit for a 3 or higher, but many selective schools require a 4 or a 5, and some don't grant credit at all for certain scores. Always check your target college's own AP credit policy page rather than assuming a 3 will count everywhere.

When is the AP Computer Science A exam?

AP exams are administered during the College Board's annual testing window in the first two full weeks of May, with the exact date and time for each subject set by the College Board and announced the preceding fall. Check AP Central or your school's AP coordinator for this year's exact date.

Is this AP Computer Science A study guide actually free?

Yes. The unit-by-unit study guide, worked examples, practice quiz, and full-length timed practice exam on this page are all free, with no login, signup, or paywall.

Study Guide

Unit-by-unit breakdown of what the course actually covers, in teaching order.

Primitive Types

Java's primitive data types (int, double, boolean, char), variable declaration and initialization, arithmetic operators including integer division and the modulus operator, operator precedence, and type casting between int and double, including the precision loss that occurs when casting double to int.

Using Objects

Instantiating objects with the 'new' keyword and constructors, calling instance methods and understanding the distinction between void and value-returning methods, object references versus primitive values (and how this affects parameter passing and aliasing), and using built-in classes like String and Math.

Boolean Expressions & if Statements

Relational operators (==, !=, <, >, etc.) and logical operators (&&, ||, !) including short-circuit evaluation, if/else if/else chains and nested conditionals, and De Morgan's laws for simplifying compound boolean expressions — a frequent source of logic-error questions.

Iteration

For loops (initialization, condition, update) versus while loops, and when each is more natural to use, nested loops for processing 2-D structures, and common iteration patterns like accumulator variables, counting matches, and finding min/max values while traversing a collection.

Writing Classes

Defining classes with instance variables, constructors (including overloaded constructors), accessor (getter) and mutator (setter) methods, encapsulation via private instance variables with public methods controlling access, and the 'this' keyword for disambiguating instance variables from parameters.

Arrays

Declaring, initializing, and traversing 1-D arrays with both indexed for-loops and enhanced for-loops, common array algorithms (finding max/min, computing a sum/average, searching for a value, reversing), and the distinction between array length (a field, no parentheses) versus String length() (a method).

ArrayLists

The ArrayList<E> generic class and its key methods (add, remove, get, set, size), traversing an ArrayList with both standard and enhanced for-loops (and the ConcurrentModificationException risk when removing elements during an enhanced for-loop), and converting between arrays and ArrayLists.

2-D Arrays

Declaring and initializing 2-D arrays (arrays of arrays), traversing with nested loops (row-major vs. column-major order), and common 2-D array algorithms like summing rows/columns, finding a value, and processing grid-like data — a frequent, heavily-weighted FRQ topic.

Inheritance

The 'extends' keyword for creating subclasses, method overriding (same signature, different implementation) versus overloading (different signature), the 'super' keyword for calling a superclass's constructor or methods, and polymorphism — how a superclass reference can point to a subclass object and calls the overridden method at runtime.

Recursion

Writing recursive methods with a base case (stopping condition) and a recursive case that moves toward it, tracing recursive calls using a call stack/trace diagram, and classic recursive algorithms including factorial, Fibonacci, and recursive array/2-D array traversal — a topic many students find conceptually difficult and worth extra practice.

Worked Examples

Concrete, fully worked examples — this is what separates a page reviewers see as genuinely useful from one that just lists topics.

Primitive Types

What does this print? int a = 7; int b = 2; double result = a / b; System.out.println(result);

Output: 3.0, not 3.5. a / b is integer division (7/2 = 3, remainder discarded) that happens before the result is ever assigned to a double. The fix is casting an operand first: (double) a / b.

Using Objects

What does this print? String s = "Hello"; String t = new String("Hello"); System.out.println(s == t);

Output: false, even though s.equals(t) would be true. == compares object references (memory addresses), not content — two separately constructed String objects have different references even with identical characters.

Boolean Expressions & if Statements

Simplify using De Morgan's law: !(x > 5 && y < 10).

Equivalent to (x <= 5 || y >= 10) — negating an AND flips it to an OR, and each individual comparison also flips (negating > gives <=, negating < gives >=).

Iteration

Trace this nested loop: for (int i=1; i<=3; i++) { for (int j=1; j<=i; j++) System.out.print("*"); System.out.println(); }

Output is a right triangle: *, then **, then *** on three lines. The outer loop controls the row; the inner loop's upper bound depends on the outer variable — this pattern (an inner bound tied to the outer counter) is a recurring FRQ structure.

Arrays

Find the maximum in int[] arr = {3, 7, 2, 9, 4};

Initialize max = arr[0] (= 3), then loop from index 1, updating max whenever a larger value appears. Final answer: 9. The classic trap is initializing max = 0 instead — that silently fails whenever every array value is negative.

ArrayLists

Why does this throw an exception? Removing elements from an ArrayList inside an enhanced for-loop.

It throws ConcurrentModificationException — modifying a collection's size while an enhanced for-loop iterates over it is never safe. The fix: iterate backwards with an indexed for-loop, or use an Iterator's own remove() method.

2-D Arrays

Sum each row of a 2-D array and store the results in a 1-D array.

Use a nested loop: the outer loop walks rows, the inner loop walks columns accumulating a running sum that resets to 0 at the start of each new row — forgetting that reset (carrying a total across rows) is the single most common bug in this pattern.

Inheritance

What gets called? Animal a = new Dog(); a.makeSound();, where Dog overrides makeSound().

Dog's version runs — polymorphism means the method called depends on the object's actual runtime type (Dog), not the reference's declared type (Animal). This dynamic dispatch is the mechanism behind most FRQ inheritance questions.

Recursion

Trace factorial(4) given factorial(n) { return n <= 1 ? 1 : n * factorial(n-1); }

Calls unwind down to factorial(1) = 1, then multiply back up: 2×1, 3×2, 4×6 = 24. Every recursive method needs a base case that stops the recursion and a recursive case that provably moves toward it — missing either causes infinite recursion and a StackOverflowError.

Study Tips

  • Practice writing full class definitions by hand, with correct syntax — partial credit rewards working code, not pseudocode.
  • Recursion and 2-D array traversal show up almost every year; drill both until they're automatic.
  • Trace FRQ code by hand with a table of variable values before writing your final answer — CS A is graded on correct method logic, and partial credit goes to correct pieces even when the final output is wrong.
  • Know the exact difference between == (reference equality for objects) and .equals() (content equality) cold — it's one of the most frequently tested conceptual traps on the exam.
  • Before coding a 2-D array FRQ, state out loud whether you're iterating row-major (outer loop = rows) or column-major (outer loop = columns) — mixing the two up is the most common cause of a broken nested loop.

Common Mistakes, Ranked by Point Loss

The errors that cost the most points across the whole exam, not just one unit.

  • 1. Confusing == (reference equality) with .equals() (content equality) for objects, leading to unexpected false results comparing Strings.
  • 2. Off-by-one loop bounds (<= versus <) that skip the last array element or throw an ArrayIndexOutOfBoundsException.
  • 3. Writing a recursive method with no base case, or a recursive case that doesn't actually shrink toward one, causing infinite recursion.
  • 4. Dividing two ints and expecting a decimal result without casting an operand to double first.
  • 5. Removing from an ArrayList during an enhanced for-loop instead of an indexed loop or an Iterator's remove().

Practice Quiz

Unofficial practice questions written for this study guide — not official AP content and not from College Board. Use them to self-check, then use the real past free-response questions below for authentic exam practice.

Coding Practice

Unofficial practice exercises. Write your solution, then reveal a sample solution and self-grade against the rubric — there's no compiler here to run your code automatically.

  • Write real, compilable Java syntax — semicolons, braces, correct types. Pseudocode-style answers lose credit on the real exam.
  • Think through edge cases (empty array, n=0, negative numbers) before you consider your solution done.
  • Compare your code line-by-line against the sample solution's logic, not just whether you got the same final output on one example.

Full Exam Simulation

Unofficial practice, timed to feel like the real thing. Section I pulls from this page's full multiple-choice bank; Section II gives you free-response prompts to write out and self-score against a rubric. Bank size is still growing toward full exam length — timing is paced per-question, not pulled from this subject's official duration.

Section I: 15 multiple-choice questions (~22 min) · Section II: 2 free-response prompts (~30 min)
Section I: Multiple Choice --:--