Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 6: Array
Start Practice TestPractice Test
Marked for reviewAbout Exam
easy Solved by 11 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

Compilation Error

B

No error, prints 0

C

ArrayIndexOutOfBoundsException

D

NullPointerException

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total 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
#7gopangjan89301 0m 06s -16
#8geethasailaja14 9m 28s -498
Items per page:
10
1 – 8 of 8
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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