2D Array Initialization Type Mismatch
What is the result of attempting to compile the following code segment?
public class Arr2D{
private int [][] arr;
Arr2D( int rows, int columns){
arr = new String[rows][columns];
}
}
A
Runtime error because the array is not initialized properly.
B
Compilation error due to type mismatch: cannot convert String[][] to int[][].
C
No error; the code compiles and runs as intended.
D
ArrayIndexOutOfBoundsException during execution.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | varunrajaram1 | 2 | 2 | 1m 33s | 107 |
| #2 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #3 | bommasam000 | 1 | 1 | 0m 11s | 89 |
| #4 | psak12 | 1 | 1 | 0m 26s | 74 |
| #5 | midnightasdark | 1 | 2 | 0m 44s | 46 |
| #6 | y.seong2027 | 2 | 2 | 2m 35s | 45 |
| #7 | dobaonam8386 | 1 | 2 | 0m 58s | 32 |
| #8 | singhris000 | 1 | 1 | 1m 16s | 24 |
| #9 | ponneban000 | 1 | 2 | 1m 27s | 3 |
| #10 | mullameh001 | 3 | 4 | 7m 30s | -160 |
Items per page:
10
1 – 10 of 12
APFIVE