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!