ACSP / JV / 01
AP Computer Science A
Every unit, with weekly practice sets.
Open the syllabusUnited States · Grades 10 to 12 · AP Computer Science A, Java
Here is a practice set you can actually trust: fourteen multiple-choice questions and one free-response task in the style of the current AP Computer Science A exam, all written by our teachers, none copied from College Board. Every answer on this page is the real output of the code, because we compiled and ran each snippet before publishing. Work through a unit at a time, write your answer down before you scroll to the key, and pay most attention to the questions you get wrong, since each one is built around a mistake students really make.
Live teaching since 2020 · 10,000+ students · Every answer run in Java
In short
These are 14 original AP Computer Science A style multiple-choice questions and one free-response task, spread across the four units of the current course in roughly the exam’s proportions. Answers and explanations follow each unit. Every snippet was compiled and run by us, so the keys are real program output. For official practice, use AP Classroom and the Bluebook test previews. Modern Age Coders teaches this live online for US students, in a batch or one to one, and the first class is free.
Keep practising, with a teacher
A practice set shows what you get wrong. A teacher shows you why, and gives you the next ten questions on exactly that idea.

ACSP / 01
Grades 10 to 12. Unit by unit, then full timed papers.
Open the syllabus →
ACSP / 02
Ages 13 to 18. Java from the first line, at a gentler pace.
Open the syllabus →
ACSP / 03
Ages 13 to 18. Harder problems once AP feels easy.
Open the syllabus →How the set is built
We wrote the questions to match the current course framework, which College Board revised for the 2025 to 2026 school year into four units. More questions go to the units the exam weights more.
| Unit | Exam weighting for Section I | Questions here |
|---|---|---|
| Unit 1: Using Objects and Methods | 15 to 25% | 3 |
| Unit 2: Selection and Iteration | 25 to 35% | 4 |
| Unit 3: Class Creation | 10 to 18% | 2 |
| Unit 4: Data Collections | 30 to 40% | 5 |
College Board’s student page lists what the multiple choice asks. You will be asked to "Determine the required code segments to produce a given output", to "Identify the output, value, or result of given program code based on initial values", and to "Analyze program code for correctness, equivalence, and errors".
Most questions here are the second kind: read the code, predict the output. That is the skill students most often skip in class, because the computer will always tell you the answer. On the exam it will not.
The Course and Exam Description says: "Designing and implementing inheritance relationships are outside the scope of the AP Computer Science A course and exam." So there are no questions here asking you to design subclasses.
Every Java method used in the set appears on the Java Quick Reference that is built into Bluebook: substring, indexOf, length, split, Math.random, and the ArrayList methods add, get, size and remove.
Sources, read 17 October 2026: the AP CSA Course at a Glance, the Java Quick Reference and the AP CSA exam page for students. The questions are ours; we are not connected with College Board.
Unit 1 · Using Objects and Methods
Three questions on the ideas that the rest of the course is built on. Each looks easy. Each has a trap that catches students who read too fast.
int a = 7; int b = 2; double c = a / b; System.out.println(c + (double) a / b);
(A) 6.0 (B) 6.5 (C) 7.0 (D) 3.5
String s = "computer";
String t = s.substring(3, 6) + s.indexOf("u") + s.length();
System.out.println(t);(A) put48 (B) pute48 (C) mpu48 (D) put12
// Which expression gives a random int // from 5 to 12, both included? (A) (int) (Math.random() * 12) + 5 (B) (int) (Math.random() * 8) + 5 (C) (int) (Math.random() * 7) + 5 (D) (int) Math.random() * 8 + 5
Pick one of (A) to (D).
| Question | Answer | Why |
|---|---|---|
| 1 | (B) 6.5 | a / b is integer division, so c holds 3.0, not 3.5. The second term casts a to double first, so it is 3.5. Then 3.0 + 3.5 is 6.5. |
| 2 | (A) put48 | substring(3, 6) takes indexes 3, 4 and 5: "put". Then the + signs run left to right on a String, so 4 and 8 are joined as text, not added to make 12. |
| 3 | (B) | Math.random() gives a value from 0.0 up to but not including 1.0. Times 8 gives 0 up to 7.99, the cast makes 0 to 7, plus 5 makes 5 to 12. In (D) the cast applies to Math.random() alone, which is always 0, so it always gives 5. |
Java decides the type of an expression from its operands, not from the variable that receives it. Declaring c as double does not rescue a / b, because the division has already happened with two ints.
Our test run of the random expression in Question 3, a million times, never produced anything below 5 or above 12, which is a good habit to copy: when in doubt about a range, test the edges.
The 2025 Chief Reader report, written about the older exam format, advised teachers: "Practice creating a random number in a given range." It also noted that many students had been drilled on a formula without understanding it.
The formula is worth understanding rather than memorising: the number you multiply by is how many different values you want, and the number you add is the smallest one. Here that is 8 values starting at 5.
Unit 2 · Selection and Iteration
Unit 2 carries up to 35 percent of the multiple choice. These four questions are about counting carefully: how many times a loop runs, and what is true when it stops.
int count = 0;
for (int i = 1; i <= 20; i += 3) {
if (i % 2 == 0) {
count++;
}
}
System.out.println(count);(A) 2 (B) 3 (C) 4 (D) 7
int x = 10;
int y = 0;
while (x > 0 && y < 4) {
x -= 3;
y++;
}
System.out.println(x + " " + y);(A) 1 3 (B) -2 4 (C) -2 3 (D) 1 4
int total = 0;
for (int r = 0; r < 4; r++) {
for (int c = r; c < 4; c++) {
total++;
}
}
System.out.println(total);(A) 16 (B) 10 (C) 6 (D) 12
String w = "abcdef";
String out = "";
for (int k = w.length() - 1; k >= 0; k -= 2) {
out += w.substring(k, k + 1);
}
System.out.println(out);(A) fdb (B) eca (C) fedcba (D) bdf
| Question | Answer | Why |
|---|---|---|
| 4 | (B) 3 | i takes the values 1, 4, 7, 10, 13, 16 and 19. Seven values, but only 4, 10 and 16 are even. |
| 5 | (B) -2 4 | x goes 10, 7, 4, 1, -2 while y goes 0, 1, 2, 3, 4. After the fourth pass x is -2 and y is 4, so both halves of the condition are now false and the loop stops. |
| 6 | (B) 10 | The inner loop starts at r, so it runs 4 times, then 3, then 2, then 1. That is 4 + 3 + 2 + 1 = 10, not 4 × 4 = 16. |
| 7 | (A) fdb | k starts at 5, the last index, and drops by 2: 5, 3, 1. The characters at those indexes are f, d and b, added in that order. |
For Questions 4 and 5, write one column per variable and one row per pass of the loop. It takes a minute and it is the only reliable method under exam pressure.
Question 5 has a second lesson: with &&, the loop continues only while both conditions are true, so it stops when either one fails. Students who stop the trace when x first drops below 4 pick (A).
Question 6 is the shape behind many comparison algorithms: each element is compared only with the ones after it. Spotting the shrinking inner loop is the skill; the answer follows from it.
In Question 7 the bounds matter as much as the step. Starting at w.length() would throw an exception on the first substring call, which is why the loop starts at w.length() - 1.
Unit 3 · Class Creation
Unit 3 is the lightest unit by weight, but its ideas sit underneath the free response. Both questions are about what actually lives in memory.
public class Counter {
private static int made = 0;
private int id;
public Counter() {
made++;
id = made;
}
public int getId() { return id; }
public static int getMade() { return made; }
}
// in another class:
Counter p = new Counter();
Counter q = new Counter();
Counter r = q;
System.out.println(r.getId() + " " + Counter.getMade());(A) 3 3 (B) 2 2 (C) 2 3 (D) 1 2
public static void change(int[] arr, int n) {
arr[0] = 99;
n = 99;
}
// in main:
int[] data = {1, 2, 3};
int k = 1;
change(data, k);
System.out.println(data[0] + " " + k);(A) 1 1 (B) 99 99 (C) 99 1 (D) 1 99
| Question | Answer | Why |
|---|---|---|
| 8 | (B) 2 2 | Only two Counter objects are built, because Counter r = q copies a reference and calls no constructor. The second object has id 2, and the static variable made, shared by the whole class, is 2. |
| 9 | (C) 99 1 | The method receives a copy of the reference to the array, so changing arr[0] changes the real array. It also receives a copy of the int k, so n = 99 changes only the copy. |
Students who answer (A) to Question 8 believe that every variable of a class type holds its own object. Drawing boxes and arrows, one box per new, clears this up faster than any explanation.
Static variables belong to the class rather than to any one object, which is why Counter.getMade() is called on the class name.
The 2026 Scoring Guidelines say an algorithm point is not earned when "Persistent data is modified (e.g., changing value referenced by parameter)." In other words, changing an array or list you were handed, when the task did not ask for it, can cost a point.
Question 9 is that rule in miniature: arr[0] = 99 reaches back into the caller’s data, and n = 99 does not.
Unit 4 · Data Collections
Unit 4 is the heaviest unit, at 30 to 40 percent of Section I, and the one most students reach last. These five questions are the ones we see cause the most lost marks.
ArrayList<Integer> nums = new ArrayList<Integer>();
nums.add(4); nums.add(4); nums.add(5);
nums.add(4); nums.add(6);
for (int i = 0; i < nums.size(); i++) {
if (nums.get(i) == 4) {
nums.remove(i);
}
}
System.out.println(nums);(A) [5, 6] (B) [4, 5, 6] (C) [4, 5, 4, 6] (D) An IndexOutOfBoundsException
int[][] g = {{1, 2, 3}, {4, 5, 6}};
int sum = 0;
for (int col = 0; col < g[0].length; col++) {
sum += g[g.length - 1 - col % 2][col];
}
System.out.println(sum);(A) 9 (B) 12 (C) 10 (D) An ArrayIndexOutOfBoundsException
public static boolean hasPair(int[] a, int target) {
for (int i = 0; i < a.length - 1; i++) {
if (a[i] + a[i + 1] == target) {
return true;
} else {
return false;
}
}
return false;
}
// in main:
System.out.println(hasPair(new int[] {3, 1, 6, 4}, 10));(A) true (B) false, because the loop returns on its first pass (C) false, because no two values add to 10 (D) It does not compile
public static int mystery(int n) {
if (n < 3) {
return n;
}
return mystery(n - 1) + mystery(n - 3);
}
// in main:
System.out.println(mystery(6));(A) 5 (B) 7 (C) 8 (D) 9
String[] parts = "red,green,,blue".split(",");
System.out.println(parts.length);(A) 3 (B) 4 (C) 5 (D) It throws an exception
| Question | Answer | Why |
|---|---|---|
| 10 | (B) [4, 5, 6] | Removing at index i shifts every later element left by one. After removing the first 4, the second 4 moves into index 0, but i moves on to 1, so that 4 is never checked. |
| 11 | (B) 12 | % runs before -, so the row is 1 - col % 2: rows 1, 0, 1 for columns 0, 1, 2. That picks 4, 2 and 6, and 4 + 2 + 6 = 12. |
| 12 | (B) | The else branch returns false on the very first pass, after checking only 3 + 1. The pair 6 + 4 at the end is never reached. |
| 13 | (B) 7 | mystery(0) to mystery(2) return 0, 1 and 2. Building up: mystery(3) is 2, mystery(4) is 3, mystery(5) is 5, and mystery(6) is 5 + 2 = 7. |
| 14 | (B) 4 | split keeps the empty string between the two commas, so the array is red, green, an empty string, and blue. |
Question 12 copies a real pattern. Writing about the 2025 free response, the Chief Reader described "a common algorithmic error being a too-early return" in a question about searching a 2D array for pairs.
The fix is to return false only after the loop has finished, so every pair gets checked: delete the else branch entirely. If you picked (C), you checked the values but not the code’s path through them.
Question 10 is the classic ArrayList trap. Two safe fixes: traverse backwards from the last index, or only increase i when nothing was removed. Both versions print [5, 6] when we run them.
In Question 13, build the answer from the bottom up instead of expanding the calls from the top. Writing mystery(0) to mystery(6) in a row takes seconds and avoids a tree of twenty calls.
Free response, our own
Question 3 of the current exam asks students to write one method that analyses data in an ArrayList. This original question is in that style, followed by one correct solution and a five-point rubric we wrote in the spirit of the published guidelines.
The task (ours). A TempLog object stores whole-number temperature readings, in order, in an ArrayList of Integer values called readings. Write the method longestRise, which returns the length of the longest run of consecutive readings in which each reading is strictly greater than the one before it. A single reading counts as a run of length 1. If there are no readings, return 0. For the readings 61, 64, 63, 66, 70, 72, 71 the method returns 4, because 63, 66, 70, 72 is the longest rising run.
import java.util.ArrayList;
public class TempLog {
private ArrayList<Integer> readings;
public TempLog(ArrayList<Integer> readings) {
this.readings = readings;
}
/** Returns the length of the longest run of
* readings that rise every time. */
public int longestRise() {
if (readings.size() == 0) {
return 0;
}
int most = 1;
int run = 1;
for (int i = 1; i < readings.size(); i++) {
if (readings.get(i) > readings.get(i - 1)) {
run++;
} else {
run = 1;
}
if (run > most) {
most = run;
}
}
return most;
}
}Compiled and run by us. Test results: 61, 64, 63, 66, 70, 72, 71 gives 4; 50, 50, 50 gives 1; no readings gives 0; 40, 41, 42 gives 3.
| Point | Earned when the response |
|---|---|
| 1 | Accesses every reading in the list without going out of bounds |
| 2 | Compares each reading with the one before it using get, not [ ] |
| 3 | Keeps a running length that grows on a rise and resets to 1 otherwise |
| 4 | Keeps the longest run seen so far and updates it correctly (algorithm) |
| 5 | Returns the correct value in every case, including no readings and one reading (algorithm) |
Starting the loop at 0 and comparing get(i) with get(i - 1) throws an exception on the first pass. Starting at 1 is the whole trick.
Updating the longest run only inside the else branch misses a run that lasts until the end of the list, such as 40, 41, 42. That response would return 1 instead of 3 and lose the algorithm point for the return value.
The 2026 Scoring Guidelines list reversed collection access, "[] instead of .get", among the reasons an algorithm point is not earned when it is not otherwise assessed. readings is an ArrayList, so readings[i] is not Java at all.
For a step-by-step method for writing these answers, see our guide to reading code and our post on how to get a 5 in AP Computer Science A.
After the set
Fourteen questions are a sample, not an exam. Use them to find a weak unit, then practise that unit properly.
Go back to casting, integer division and String methods. They come back in every later unit, often hidden inside harder questions.
Practise trace tables until they are automatic. Most loop and list mistakes are counting mistakes, not knowledge gaps.
Time yourself on full sections. The real Section I is 42 questions in 90 minutes, a little over two minutes each.
For official material, College Board points students to AP Classroom and to the test previews in the Bluebook app. Past free-response questions are on AP Central too, but College Board warns that after the 2025 to 2026 revisions they do not completely align with the current exam, so use them for practice in writing code rather than for timing. Our AP Computer Science A classes set new questions like these every week.
How students improve
Most students move through these in order. Knowing which one you are at tells you what to practise.
| Stage | What it looks like |
|---|---|
| 1. Running it | Types the code into an editor to find the answer |
| 2. Tracing it | Predicts the output on paper, then checks |
| 3. Spotting the trap | Sees the integer division or the shifted index at once |
| 4. Writing it | Writes full methods that earn every rubric point |
Stage 1 is where most students begin. It is fine for learning, and not allowed on the exam.
The move from stage 2 to 3 usually comes from volume: a few hundred well-chosen questions.
Commit to an answer before you check. Guessing then checking teaches nothing.
Keep a list of the traps that caught you. It will be shorter than you expect.
The catalogue
Live online, the same teacher each week, as a batch or one to one.
ACSP / JV / 01
Every unit, with weekly practice sets.
Open the syllabusACSP / JV / 02
The language, properly, from scratch.
Open the syllabusACSP / JV / 03
The broader AP course.
Open the syllabusACSP / AL / 01
Searching, sorting and lists, deeper.
Open the syllabusACSP / AL / 02
Contest problems, USACO style.
Open the syllabusACSP / AL / 03
Quick scripts and projects beside Java.
Open the syllabusACSP / BLD / 01
Real web apps, front to back.
Open the syllabusACSP / BLD / 02
Data sets and first models.
Open the syllabusACSP / BLD / 03
Interactive pages and games.
Open the syllabusHow lessons run
Weekdays or weekends, flexible: choose your batch, or for a very personalised plan choose 1-on-1 at your convenience, weekend mornings or weekdays.
Weekdays
Evening slots work across the US time zones.
Weekends
Room for a full timed section.
1-on-1
Arranged around tests at school.
Who remembers last week’s mistakes.
Predict on paper first, every time.
Written for the student’s weak units.
Point by point, with reasons.
Any state, any school district.
Fifteen to twenty, or one learner.
Student work
Apps and games by young people who practised exactly this kind of Java with us. The student labs page shows more.

AI and ML
An AI nutrition coach that reads what you eat and works you toward a target.

AI and ML
A chatbot that answers mathematics and programming questions, built and deployed by a student.

AI and ML
An assistant that helps a young person recognise unsafe situations online.

Web app
A weather forecasting site with live conditions for any location.
Fees
The practice set is free. Classes are paid month by month in US dollars, with nothing to sign for the year and no fee to stop.
Free first class
USD 0
no card required
Group batch
USD 100
a month, billed in US dollars
One to one
USD 150
a month, billed in US dollars
What families say
Parents’ Google reviews, unedited.
★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
★★★★★
"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."
Samriddha Mondal
Student
★★★★★
"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."
Vansh Agarwal
Student
★★★★★
"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."
Sonam Oswal
Parent of Dhairya
★★★★★
"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."
Sonu Goyal
Parent
★★★★★
"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."
Ritu Kedia
Parent
Questions from students
No. Every question on this page was written by our teachers in the style of the current exam. College Board items are not copied. For official practice, use AP Classroom and the Bluebook test previews.
We compiled and ran every snippet with Java before publishing, so each answer is the actual output of the code.
There are 42 of them in Section I, with 90 minutes to answer, and together they make up 55% of the exam score.
Unit 4, Data Collections, has the largest multiple-choice weighting, 30 to 40 percent, followed by Unit 2, Selection and Iteration, at 25 to 35 percent.
College Board says designing and implementing inheritance relationships are outside the scope of the course and exam, so this set does not test it.
The Java Quick Reference in Bluebook lists them, including String substring, indexOf and split, Math.random, and the ArrayList methods add, get, set, size and remove.
For practice in writing Java, yes. College Board notes that questions from before the 2025 to 2026 revisions are not fully matched to the current exam, so do not use them to judge timing or scoring.
Removing at index i shifts every later element one place left, and then i increases, so the element that moved into position i is never checked. Traversing backwards avoids it.
Weekdays or weekends, flexible. Choose your batch, or for a very personalised plan choose 1-on-1 at your convenience, weekend mornings or weekdays.
The first lesson is free. After it, classes are paid one month at a time, and the fees section shows the monthly amount in US dollars.
Elsewhere on this site
More for US students learning Java for AP.
The full live course.
The four-unit course explained.
A method for finding your own bugs.
The habits behind tracing.
When AP questions get easy.
All our pages for US families.
The AP CSP Create task from the official handouts: code, video, PPR, AI rules, deadline.
How hard are AP CSA and AP CSP? The 2026 numbers, the prerequisites, two quick checks.
Java cannot find symbol, decoded: real javac output, eight causes, numbered fixes.
Start here
Send the questions you got wrong here, or from class. The teacher goes through two of them with your teen and then sets three new ones on the same idea.
Want to know how a class runs? Read how we teach, or open the courses to see each syllabus.
WhatsApp us · +91 91233 66161 · connect@modernagecoders.com
Lessons are live on video, taught by teachers who work from India, so families in any state can join without travelling. A WhatsApp message is the quickest route to us.
A priority demo is a full class of about 45 to 60 minutes. After the class the mentor sends a written skill report and a personal learning roadmap on WhatsApp. If you enrol, the demo fee is adjusted against your first month's fee. Share your demo Order ID with us on WhatsApp and we take it off.
Book a priority demo