Home › Educational › Advanced Placement (AP) › AP Computer Science A

AP Computer Science A practice questions and exam guide

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.

Last reviewed 2026-10-26 · CoStudy · how we write and review questions

  • 360 total items
  • 150 multiple choice
  • 210 flashcards

Study AP Computer Science A in CoStudy →

About the AP Computer Science A exam

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.

Free AP Computer Science A practice questions

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]);

  1. 30
  2. null
  3. ArrayIndexOutOfBoundsException
  4. 0

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:

  1. Dog is a subclass; Animal is the superclass; Dog INHERITS from Animal (gets fields/methods FROM parent)
  2. Animal inherits from Dog
  3. They share equal status
  4. Neither inherits

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)?

  1. true
  2. Error
  3. false
  4. null

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:

  1. Provides a dynamic-size, ordered collection with methods like add, remove, get, size — backed by an internal resizable array
  2. Stores only primitives
  3. Cannot be iterated
  4. Has fixed size like primitive arrays

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:

  1. 3.5
  2. 3 (truncates toward zero); to get 3.5, cast one operand to double: 7 / 2.0 = 3.5
  3. 4
  4. An error

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?

  1. Only from inside its declaring class (including its own methods); not from subclasses or other classes
  2. Anywhere
  3. Only from subclasses
  4. Only from same package

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");

  1. 8
  2. 5
  3. 3
  4. 15

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?

  1. ArrayList uses size() (method with parentheses); arrays use length (field, no parens) — common AP CSA trap question
  2. No difference
  3. Both are methods
  4. Both are fields

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);

  1. 3.3333333333333335
  2. 3.0
  3. 3
  4. 3.33

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:

  1. equals() only
  2. compareTo(Object other) — returns negative, zero, or positive int based on natural ordering — used by sorting algorithms
  3. toString() only
  4. hashCode() only

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);

  1. Error: Integer != int
  2. null
  3. 53
  4. 8

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);

  1. "ABC"
  2. Error
  3. "Abc"
  4. "abc"

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().

AP Computer Science A flashcards

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.).

Practise the full AP Computer Science A bank

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.

Open AP Computer Science A →

AP Computer Science A — frequently asked

What is the AP Computer Science A exam?

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)

How is CoStudy’s AP Computer Science A bank organised?

It holds 360 items (150 multiple-choice, 210 flashcards). Free samples on this page include the full rationale, with no account.

Does CoStudy replace the College Board?

No. the College Board owns the outline, the badge, and the sitting rules. This is independent practice with written rationales. We do not sell live items and we do not guarantee a pass.

Where do AP Computer Science A fees, cut scores, and pass rates live?

On the College Board’s published pages — start at the AP Course and Exam Descriptions. This page quotes a number only when we retrieved it from an official URL, and otherwise says unverified. Prep blogs that tabulate every exam’s price are often stale.

Are these real AP Computer Science A exam questions?

No. CoStudy does not have live items. The samples below are original practice written to the published outline, with rationales. Anyone selling “real exam dumps” is describing something you should not buy.

Primary source

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.

Related study guides

Related subjects

Browse professional certification banks →