Populating a 2D Array with Nested Loops
Consider the following code segment.
int[][] data = new int[3][3];
for (int m = 0; m < data.length; m++)
{
for (int n = 0; n < data[0].length; n++)
{
data[m][n] = m * n;
}
}
What are the contents of the data array after this code segment is executed?
A
0 0 0
0 1 2
0 2 4
B
1 1 1
2 2 2
3 3 3
C
0 1 2
0 2 4
0 3 6
D
1 2 3
2 4 6
3 6 9
Question Leaderboard
Not enough data yet to show leaderboard.
