Java Topic Practice
2D Array Traversal
2D Array Traversal MCQ Practice
Question 1 of 15
Answered 0 of 15
Choose one answer.
What is printed by the following code segment?
int[][] grid = {
{2, 5, 1},
{4, 3, 6},
{7, 0, 8}
};
String out = "";
for (int c = 0; c < grid[0].length; c++) {
for (int r = 0; r < grid.length; r++) {
out += grid[r][c] + " ";
}
}
System.out.print(out.trim());