Tracing Nested Loops on a 2D Array
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
Question Leaderboard
Not enough data yet to show leaderboard.
