Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a 2D array of integers with 3 rows and 4 columns.
Java
int[][] matrix = new int[[1]][4];
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to access the element in the second row and third column of a 2D array named 'grid'.
Java
int value = grid[[1]][2];
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the code to correctly initialize a 2D array with 2 rows and 3 columns.
Java
int[][] arr = new int[[1]][3];
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill 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.
Java
int[][] table = new int[[1]][[2]]; table[0][[2] - 1] = 10;
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a 2D array 'matrix', assign 7 to the element at row 2, column 3, and print that element.
Java
int[][] matrix = new int[[1]][[2]]; matrix[[3]][3] = 7; System.out.println(matrix[2][3]);
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
