Home › Certifications › AP Computer Science A
150 multiple-choice questions and 210 flashcards, written to the College Board AP Computer Science A Course and Exam Description blueprint. Every question carries a full rationale.
Study AP Computer Science A in CoStudy →
College Board AP Computer Science A Course and Exam Description — 10 CED units: Primitive Types; Using Objects; Boolean Expressions & if-statements; Iteration; Writing Classes; Array; ArrayList; 2D Array; Inheritance; Recursion (Java-based)
CoStudy's AP Computer Science A bank holds 360 items. Every multiple-choice question carries a written rationale explaining why the correct answer is correct and why each distractor is tempting but wrong.
A sample of 12 multiple-choice questions from the bank, with the full rationale shown.
What is printed? int[] arr = {10, 20, 30}; System.out.println(arr[3]);
Answer: C — ArrayIndexOutOfBoundsException
Valid indices: 0, 1, 2. arr[3] is out of bounds (length 3, indices 0..2). Throws ArrayIndexOutOfBoundsException at runtime.
Trap: which direction does inheritance flow? If Dog extends Animal:
Answer: A — Dog is a subclass; Animal is the superclass; Dog INHERITS from Animal (gets fields/methods FROM parent)
Inheritance flows from parent (super) to child (sub). Child gets parent's accessible members. Child is more specific. 'super' refers to parent. Reversing super/sub is a common conceptual error.
What is the value of the Boolean expression: (5 > 3) && (2 < 1)?
Answer: C — false
Java logical AND (&&): both must be true. First condition true; second false → overall false. Logical OR (||): either true → true. Logical NOT (!): inverts. Short-circuit: && stops if first false; || stops if first true.
An ArrayList in Java differs from a primitive array because it:
Answer: A — Provides a dynamic-size, ordered collection with methods like add, remove, get, size — backed by an internal resizable array
A) Defining property of ArrayList. B/C/D) Each contradicts.
Integer division in Java (e.g., 7 / 2) yields:
Answer: B — 3 (truncates toward zero); to get 3.5, cast one operand to double: 7 / 2.0 = 3.5
If both operands int → result int (truncates, not rounds). Common bug. Solutions: (double) 7 / 2 = 3.5, or 7.0 / 2 = 3.5. Modulo: 7 % 2 = 1 (remainder). For negative: −7 / 2 = −3 (toward zero), −7 % 2 = −1.
Where can a private instance field be accessed?
Answer: A — Only from inside its declaring class (including its own methods); not from subclasses or other classes
private: visible ONLY within the same class. Encapsulation. Subclasses cannot directly access private fields of parent (use protected or public getter).
How many total prints occur? for (int i = 0; i < 3; i++) for (int j = 0; j < 5; j++) System.out.print("X");
Answer: D — 15
Nested loops: outer × inner = 3 × 5 = 15 prints. Standard pattern for 2D iteration.
What is the difference between list.size() and arr.length?
Answer: A — ArrayList uses size() (method with parentheses); arrays use length (field, no parens) — common AP CSA trap question
Three distinct: array.length (field), ArrayList.size() (method), String.length() (method). Mixing them up is a common syntax error and AP exam target.
What is printed? int a = 10; int b = 3; double c = a / b; System.out.println(c);
Answer: B — 3.0
Trap: a / b is int division (= 3) BEFORE the result is assigned to double c. So c = 3.0. To get 3.333..., cast first: (double) a / b.
If a class implements the Comparable interface, it must implement:
Answer: B — compareTo(Object other) — returns negative, zero, or positive int based on natural ordering — used by sorting algorithms
Comparable<T> interface: int compareTo(T other). Returns negative if 'this' < other, zero if equal, positive if 'this' > other. Used by Collections.sort() and Arrays.sort() to order elements. Should be consistent with equals() (a.compareTo(b) == 0 should imply a.equals(b)).
What does this print? Integer x = 5; int y = x + 3; System.out.println(y);
Answer: D — 8
Autoboxing/unboxing: Integer x = 5 boxes int 5 into Integer. x + 3 unboxes x to int, then adds. y = 8.
What is printed? String s = "abc"; s.toUpperCase(); System.out.println(s);
Answer: D — "abc"
Strings are immutable. toUpperCase() returns a NEW string but the original s is unchanged. The return value is discarded here. To save: s = s.toUpperCase().
6 sample cards from the 210 in the bank.
Why is mergesort more efficient than bubble sort for large arrays?
Mergesort: O(n log n). Bubble: O(n²). For n = 1000: log n ≈ 10, n = 1000 → mergesort ~10,000 operations vs. bubble 1,000,000.
What's the difference between = and ==?
= : assignment. ==: comparison (returns boolean).
Common error: forgetting return statement.
Non-void method must return on every path. Compile error otherwise.
When is `boolean b = (x > 0);` true?
When x is greater than 0.
What is integer division in Java?
Division of two ints truncates toward zero. 7/2 = 3 (not 3.5).
What's the AP CSA Quick Reference?
Provided on exam: signatures of common Java library methods (String, Math, ArrayList, etc.).
These samples are a small slice. The full bank runs flashcards, multiple choice and timed mock exams with per-chapter progress tracking, on the web and in the iOS app.
The AP Computer Science A bank holds 360 items: 150 multiple-choice questions, 210 flashcards. 18 of them are on this page to read free, with no signup.
Yes. Every multiple-choice item carries a written rationale that states the controlling principle behind the correct answer and then addresses each wrong option in turn — why it tempts and precisely where it fails. Knowing why the plausible answer was wrong is worth more than knowing which letter was right.
College Board AP Computer Science A Course and Exam Description — 10 CED units: Primitive Types; Using Objects; Boolean Expressions & if-statements; Iteration; Writing Classes; Array; ArrayList; 2D Array; Inheritance; Recursion (Java-based)
The samples on this page are free to read in full, rationales included, with no account. The complete 360-item bank, the timed mock exams and per-chapter progress tracking are part of CoStudy on the web and in the iOS app.
Last reviewed 2026-08-22. Banks are written against the certifying body's published exam outline and re-checked when that outline changes — exams get renumbered, retired and reweighted, and a bank written to a superseded outline teaches the wrong proportions. Figures that are re-indexed annually are deliberately not asserted as rules; the questions test the governing principle instead.
This bank is written against the College Board's published exam material. Check the AP Course and Exam Descriptions for the current outline, fees and eligibility rules — those change, and the certifying body is the only authority on them. CoStudy is not affiliated with the College Board.