| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice Test
Share
medium Solved by 6 students
Dereferencing a Null 2D Array Row
< Prev
Next >

What is the result when the following code is executed?

public class NullRow {
    public static void main(String[] args) {
        int[][] arr = new int[2][];
        arr[0] = new int[]{1, 2};
        arr[1] = null;
        System.out.println(arr[1].length);
    }
}
A

0

B

2

C

Compilation error

D

NullPointerException at runtime

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Not enough data yet to show leaderboard.

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy