2D Array Traversal and Modification
Consider the following code segment. What is printed when the code segment is executed?
int[][] matrix = { {1, 2}, {3, 4} };
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
matrix[i][j] += 1;
}
}
System.out.println(matrix[1][1]);
A
6
B
5
C
4
D
1
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | ahsan48105 | 2 | 2 | 0m 00s | 200 |
| #2 | y.seong2027 | 0 | 2 | 3m 49s | -249 |
| #3 | bommasam000 | 2 | 5 | 7m 50s | -300 |
APFIVE