Java Programming - Objects and Collections - Discussion

Discussion Forum : Objects and Collections - General Questions (Q.No. 2)
2.
Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
java.lang.String
java.lang.Double
java.lang.StringBuffer
java.lang.Character
Answer: Option
Explanation:

java.lang.StringBuffer is the only class in the list that uses the default methods provided by class Object.

Discussion:
15 comments Page 2 of 2.

Ghost said:   1 decade ago
@Sarfaraz Ahamad.

All wrapper classes and String class overrides the equals() and hashCode().

@Pankaj Kalra.

string buffer or string builder are not classes .
The classes are StringBuffer and StringBuilder. Please follow java naming conventions.

Pankaj kalra said:   1 decade ago
Why string buffer or string builder not override these 2 mehtods ?

SArfaraz Ahamad said:   1 decade ago
But String class is not Wrapper class.

Firat said:   1 decade ago
Other classes are wrapper classes and override equals() and hashCode() methods. The StringBuffer does not override these methods.

Vidya said:   2 decades ago
can u give me the clear discription?


Post your comments here:

Your comments will be displayed after verification.