Invalid 2D Array Index Type
Identify the error that causes the code above to fail compilation.
public class IndexError {
public static void main(String[] args) {
int[][] table = { {1, 2, 3}, {4, 5, 6} };
int element = table['0'][1];
System.out.println(element);
}
}
A
Using a character literal ‘0’ as an array index instead of an integer.
B
The array ‘table’ is not properly declared.
C
Incorrect use of the System.out.println method.
D
Improper dimensions used when declaring the 2D array.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE