Complete the code to declare a 2D array of integers with 3 rows and 4 columns.
int[][] matrix = new int[[1]][4];
The first dimension specifies the number of rows. Here, 3 rows and 4 columns create a 3x4 matrix.
Complete the code to access the element in the second row and third column of a 2D array named 'grid'.
int value = grid[[1]][2];
Array indices start at 0, so the second row is index 1.
Fix the error in the code to correctly initialize a 2D array with 2 rows and 3 columns.
int[][] arr = new int[[1]][3];
To create a 2D array with 2 rows and 3 columns, you must specify both dimensions inside the brackets.
Fill both blanks to create a 2D array 'table' with 5 rows and 6 columns and assign the value 10 to the element in the first row and last column.
int[][] table = new int[[1]][[2]]; table[0][[2] - 1] = 10;
The array has 5 rows and 6 columns. The last column index is 6 - 1 = 5.
Fill all three blanks to create a 2D array 'matrix', assign 7 to the element at row 2, column 3, and print that element.
int[][] matrix = new int[[1]][[2]]; matrix[[3]][3] = 7; System.out.println(matrix[2][3]);
The array has 4 rows and 5 columns. The value 7 is assigned to row 2, column 3 (indexing from 0).
