AP Computer Science A Multiple Choice Sample Paper 2023
Many students freeze on AP Computer Science A because they haven't drilled the core patterns that appear on every section I exam—from spotting what a for-loop does to tracing through object state and inheritance chains. This sample paper mirrors the real MCQ section's mix of quick conceptual wins and deeper logic puzzles, testing your fluency with primitive types, objects, boolean logic, arrays, and class design. It's built for Grade 12 AP CS A students preparing for the May exam or refreshing core skills. Finish this paper, and you'll walk into the real exam confident that you can identify off-by-one errors, predict output from unfamiliar code, and reason through inheritance without second-guessing yourself.
Questions in this quiz
Answers hidden — play to find out.
- Question 1
What is the value of x after the following code executes? int x = 5; int y = 10; x = (int)(y / 2.0) + x;
- Question 2
Which of the following correctly declares a two-dimensional array of integers with 3 rows and 4 columns?
- Question 3
A student writes the code below. What is printed? boolean a = true; boolean b = false; if (a && !b) { System.out.println("Yes"); } else { System.out.println("No"); }
- Question 4
Which statement about objects and classes in Java is TRUE?
- Question 5
Consider a class Student with a constructor that takes a String name and an int age. Which of the following correctly creates an object of the Student class?
- Question 6
What does the following loop print? for (int i = 1; i <= 3; i++) { for (int j = 1; j <= i; j++) { System.out.print(j); } System.out.println(); }
- Question 7
An ArrayList of Strings is created as: ArrayList<String> list = new ArrayList<>(); list.add("apple"); list.add("banana"); list.add("cherry"); What is returned by list.get(1)?
- Question 8
What is the output of the code snippet below? int[] arr = {10, 20, 30}; for (int num : arr) { num = num * 2; } System.out.println(arr[0]);
- Question 9
A programmer writes a method to search an ArrayList for a specific value. The method must return true if the value is found and false otherwise. Which of the following is the best approach?
- Question 10
Consider a class hierarchy where Circle extends Shape. A programmer writes: Shape shape = new Circle(); What is this an example of?
- Question 11
A method is called with the argument 5. Inside the method, the parameter is incremented by 1. After the method returns, what is the value of the argument (the original variable) in the caller's scope?
- Question 12
Which of the following code snippets correctly sums all elements in an integer array?
- Question 13
What is the purpose of the 'super' keyword in Java?
- Question 14
A student has an array of size 5. They write a loop: for (int i = 0; i <= 5; i++) { ... }. What is the problem?