APCSA Question of the Week: 2D Arrays
Apr 28, 2025

APCSA Question of the Week: 2D Arrays
This week's question is from Unit 8: 2D Arrays. There will be 3-4 questions on the exam about 2D Arrays.
For this week's question, only 24% of students get it correct on the first try.
Try it for yourself on Passionfruit before scrolling to see the answer and explanation below!

https://app.passionfruitlearning.com/ap-computer-science-a/multiple-choice/2d-arrays-ijZyXvy
Explanation and Solution
Here's the step-by-step thought process I use whenever I see a nested-loop problem like the question above:
When analyzing any nested loop, zero in on the following key points 💡
Loop order
Which loop is outer, which is inner?
In this code snippet, columns are the outer loop; rows are the inner loop.Initial value – comparison operator – update
Where does each loop start, how does it stop, and which way does it move?The body of the loop
Exactly what is printed or changed each pass?System.out.print(grid[row][col] + " ");
This just prints the item at[row][col]
.What the question is asking for
In this case: “Which answer choice matches the printed output?”
The Quick Approach 🚀
Instead of mentally juggling indices, try a mini trace with real values by writing out the grid with row/column labels. Here's the starting 2D Array:
row\col | 0 | 1 | 2 |
---|---|---|---|
0 | X | Y | Z |
1 | P | Q | R |
2 | L | M | N |
Now we follow the loops:
col = 2
(right-most)
rows 0→2 → Z R N
(print space after each, newline after the column finishes)col = 1
→ Y Q Mcol = 0
→ X P L
We see the full output:
The Pattern 🧩
Notice what happened:
The outer loop counts columns backward ⇒ every line is a different column from right to left.
The inner loop counts rows forward ⇒ letters in each line go top → bottom.
That combination flips the grid horizontally and prints it column by column.
Option E is the only perfect fit.
Quick Tips for Similar Questions 💡
Label a tiny table if the 2D array is small (3×3 here).
Run the first two iterations—patterns jump out fast.
Track outer vs. inner loops separately.
For 2-D arrays, ask: “Am I reading rows first or columns first?”
As always, if you have any additional questions, feel free to ask Passionfruit’s AI Tutor or email us at jason@passionfruitlearning.com.
See you next time! 🍍