2D Array Traversal With Step
Consider the following method.
public void editArray(int[][] data) {
for (int row = 0; row < data.length; row += 2) {
for (int col = 0; col < data[row].length; col++) {
data[row][col] = -data[row][col];
}
}
}
An int[][] array, arr, is declared and initialized as follows.
int[][] arr = {
{-1, -2, -3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}
};
What are the contents of arr after the method call editArray(arr) is executed?
A
1, 2, 3
4, 5, 6
-7, -8, -9
10, 11, 12
B
-1, -2, -3
4, 5, 6
7, 8, 9
10, 11, 12
C
1, 2, 3
4, 5, 6
7, 8, 9
10, 11, 12
D
1, 2, 3
4, 5, 6
-7, -8, -9
-10, -11, -12
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | y.seong2027 | 1 | 2 | 1m 40s | -10 |
| #3 | winstonhou1107 | 0 | 1 | 0m 00s | -10 |
| #4 | bommasam000 | 1 | 3 | 11m 52s | -632 |
APFIVE