Multiple choice java

Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

  1. java.lang.String

  2. java.lang.Double

  3. java.lang.StringBuffer

  4. java.lang.Character

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

java.lang.StringBuffer does not override the equals() method, so it inherits the Object implementation which performs reference equality (==). Classes like String, Double, and Character override equals() to compare content/value.