← Quiz: Java Strings: all 10 questions
Quiz: Java Strings · Question 10 of 10
What does "Java".equals(name) do better than name.equals("Java")?
What does "Java".equals(name) do better than name.equals("Java")?
- A.It is faster for long strings
- B.It ignores capital letters
- C.It returns false instead of throwing NullPointerException when name is null
- D.It compares references instead of text
Answer & explanation
Correct answer: It returns false instead of throwing NullPointerException when name is null
Calling equals on the literal is safe because the literal is never null.
Can you get the rest right without peeking?
Take the timed Quiz: Java Strings quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →