Question 6
Back to Exercise
Which line throws NullPointerException if s is null?
- A if (s == null)
- B s.length() Correct
- C String t = s;
- D System.out.println(s);
Correct Answer: Option B
Comparing, assigning or printing null is fine; dereferencing it is not.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!