| preferred AP College board partner for AP classes
AP Computer Science A/Unit 6: Array
Start Practice TestPractice Test
About Exam
easy Solved by 13 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
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1bommasam00034 0m 43s 247
#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
Items per page:
10
1 – 7 of 7
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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