| preferred AP College board partner for AP classes
AP Computer Science A/Unit 6: Array
Start Practice Test
Share
easy Solved by 12 students
Java Array Null Pointer Exception
< Prev
Next >

What is the result of executing the following code segment?

public class NullObjectTest {
  public static void main(String[] args) {
      String[] words = new String[3];
      words[1] = "hello";
      System.out.println(words[0].length());
  }
}
A

NullPointerException

B

Compilation Error

C

No error, prints 0

D

ArrayIndexOutOfBoundsException

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1bommasam00033 0m 33s 267
#2sathilak00011 0m 10s 90
#3y.seong202711 0m 15s 85
#4suhanakochhar00611 0m 23s 77
#5singhris00011 0m 26s 74
#6sailajavadlamani3311 0m 56s 44
#7geethasailaja14 9m 28s -498
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy