| 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
< 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]);

When this code is executed, which will be the fifth element printed?

A

5

B

8

C

12

D

11

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy