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

Question image

Understand the Problem

The question is asking which class among the given options does not override the equals() and hashCode() methods, meaning we need to identify a class that inherits these methods directly from the Object class without any modifications.

Answer

java.lang.StringBuffer

The final answer is java.lang.StringBuffer

Answer for screen readers

The final answer is java.lang.StringBuffer

More Information

java.lang.StringBuffer does not override the equals() and hashCode() methods, so it inherits them directly from the Object class.

Tips

A common mistake is to assume that all classes in the java.lang package override equals() and hashCode(). However, some classes like StringBuffer and StringBuilder inherit these methods directly from the Object class.

AI-generated content may contain errors. Please verify critical information

Thank you for voting!
Use Quizgecko on...
Browser
Browser