AP CSA 2D Array Practice Questions with Answers (2026)

AP CSA 2D Array Practice Questions with Answers

10 exam-difficulty 2D array questions. Trace nested loops, predict output, and identify errors. Detailed explanations for every answer.

⏰ The AP CSA Exam is May 15, 2026 — Get the 4-Week Cram Kit →
🎓 How to Use This Page

For each question: read the code, trace on paper, select your answer. Feedback appears immediately. Target: 7/10 or higher means you are exam-ready on 2D arrays.

Score: 0 / 10
1.
int[][] grid = {{1,2,3},{4,5,6},{7,8,9}};
int result = 0;
for (int r = 0; r < grid.length; r++)
{
    result += grid[r][r];
}
System.out.println(result);
What is printed?
2.
int[][] m = {{5,3,8},{2,7,4},{9,1,6}};
int val = m[0][0];
for (int r = 0; r < m.length; r++)
{
    for (int c = 0; c < m[r].length; c++)
    {
        if (m[r][c] < val)
        {
            val = m[r][c];
        }
    }
}
System.out.println(val);
What is printed?
3.
int[][] t = {{1,2},{3,4},{5,6}};
System.out.println(t.length + " " + t[0].length);
What is printed?
4.
int[][] p = {{10,20,30},{40,50,60}};
int s = 0;
for (int c = 0; c < p[0].length; c++)
{
    s += p[1][c];
}
System.out.println(s);
What is printed?
5. The following code is intended to print the elements of column 0, but it contains an error.
for (int c = 0; c < grid[0].length; c++)
{
    System.out.println(grid[c][0]);
}
What is the error?
6.
int[][] d = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
int count = 0;
for (int r = 0; r < d.length; r++)
{
    for (int c = 0; c < d[r].length; c++)
    {
        if (d[r][c] % 3 == 0)
        {
            count++;
        }
    }
}
System.out.println(count);
What is printed?
7.
int[][] g = {{1,2},{3,4},{5,6},{7,8}};
for (int r = 0; r < g.length; r++)
{
    for (int c = 0; c <= r; c++)
    {
        System.out.print(g[r][c] + " ");
    }
    System.out.println();
}
What is printed? (Note: g has 4 rows and 2 columns)
8. Which of the following correctly replaces every element in a 2D array with its absolute value?
9.
String[][] w = {{"A","B"},{"C","D"}};
System.out.println(w[1][0] + w[0][1]);
What is printed?
10. A 2D array has 6 rows and 4 columns. A method uses grid[0].length as the outer loop bound and grid.length as the inner loop bound. What happens?

❓ Frequently Asked Questions

How many 2D array questions are on the AP CSA exam?

Expect 8-12 MCQ involving 2D arrays plus the entire FRQ 4. Unit 4 is 30-40% of the exam, and 2D arrays are a major component of that weight.

What makes these questions hard?

These questions use non-obvious variable names, require multi-step tracing through nested loops, and include common traps like row/column confusion and off-by-one errors at matrix boundaries.

About the Author: Tanner Crow has 11+ years of AP Computer Science teaching experience, 1,845+ verified tutoring hours, and a 5.0 rating. His students score 5s at over double the national rate. Book a tutoring session →

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]