🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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")?

  1. A.It is faster for long strings
  2. B.It ignores capital letters
  3. C.It returns false instead of throwing NullPointerException when name is null
  4. 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 →