Java Topic Practice
2D Array Basics
2D Array Basics 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}};
int total = 0;
for (int r = 0; r < grid.length; r++) {
int c = (r + 0) % grid[r].length;
total += grid[r][c] * (r + 1);
}
System.out.print(total);