0
0
Javaprogramming~15 mins

Two-dimensional arrays in Java - Interactive Code Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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
A2
B3
C5
D4
Attempts:
3 left
2fill in blank
medium

Complete 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
A2
B3
C1
D0
Attempts:
3 left
3fill in blank
hard

Fix 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
A2
B3, 2
C2, 3
D3
Attempts:
3 left
4fill in blank
hard

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.

Java
int[][] table = new int[[1]][[2]];
table[0][[2] - 1] = 10;
🎯 Drag options to blanks, or click blank then click option
A5
B6
C4
D7
Attempts:
3 left
5fill in blank
hard

Fill 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
A4
B5
C2
D3
Attempts:
3 left