LearnFrenzy
Sign in Take a free test

Strings and StringBuilder · Java Strings MCQ · Question 16

equals() on two StringBuilders Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 16 Back to Exercise

What does new StringBuilder("a").equals(new StringBuilder("a")) return?

  • A true
  • B false – StringBuilder does not override equals Correct
  • C Compile error
  • D It throws
Correct Answer: Option B

Compare sb1.toString().equals(sb2.toString()) or sb1.compareTo(sb2) == 0 (Java 11).

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links