Browse all quizzes
Computer ScienceGrade 12English

AP Computer Science A Section I Multiple Choice Sample 2023

You're about to face exactly the kind of rapid-fire, multi-concept questions the AP exam loves: where a single wrong letter can mean mixing up object references, forgetting loop bounds, or misreading a boolean expression. This sample covers the three pillars of AP CSA Section I — fundamental data types and operations, control flow through loops and conditionals, and the object-oriented concepts that trip up even strong students. You'll see questions spanning primitive types, ArrayList iteration, inheritance mechanics, and recursive logic, each one testing whether you truly understand the code or just memorised patterns. By the end, you'll have a reliable instinct for spotting off-by-one errors, understanding what objects actually are, and reading boolean expressions without second-guessing yourself.

14 questions · play in your browser
No signup required — try it for free.

Questions in this quiz

Answers hidden — play to find out.

  1. Question 1

    What is the output of the following code snippet? int x = 5; int y = ++x + x++; System.out.println(y);

  2. Question 2

    Which of the following boolean expressions will evaluate to true when x = 5 and y = 10?

  3. Question 3

    If a double variable d is assigned the value 7 / 2, what will d contain?

  4. Question 4

    What is the output of this code? for (int i = 1; i <= 3; i++) { System.out.print(i + " "); }

  5. Question 5

    A while loop is defined as: while (count < 10) { count++; }. If count starts at 5, how many times will the loop body execute?

  6. Question 6

    Consider this nested loop: for (int i = 1; i <= 2; i++) { for (int j = 1; j <= 3; j++) { System.out.print("*"); } } How many asterisks are printed?

  7. Question 7

    What is the output of the following code? if (5 > 3) { System.out.println("A"); } else if (5 == 5) { System.out.println("B"); } else { System.out.println("C"); }

  8. Question 8

    A Java class has a private variable age. Which statement is true?

  9. Question 9

    What is printed by this code? ArrayList<Integer> list = new ArrayList<>(); list.add(10); list.add(20); list.add(30); for (int num : list) { System.out.print(num + " "); }

  10. Question 10

    Given the following array: int[] arr = {1, 2, 3, 4, 5}; What is arr[2]?

  11. Question 11

    A class Student extends Person. If Person has a method calculateAge(), and Student overrides it, which version is called when a Person reference points to a Student object?

  12. Question 12

    What is the output of the following recursive method when called with mystery(3)? private static int mystery(int n) { if (n == 0) return 1; return n * mystery(n - 1); }

  13. Question 13

    A 2D array is declared as: int[][] grid = new int[2][3];. What is the size of grid?

  14. Question 14

    In a class constructor, the keyword 'this' refers to which object?