Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
About Exam
hard Solved by 1 students

Tracing Nested Loops on a 2D Array

Mark
< Prev
Next >

Consider the following code segment.

int[][] mat = {
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 9},
    {10, 11, 12}
};

for (int col = 0; col < mat[0].length; col++)
    for (int row = mat.length - 1; row >= col; row--)
        System.out.println(mat[row][col]);

What is the fifth value printed when this code segment is executed?

A

11

B

12

C

8

D

5

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|