File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes java.lang.object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "java.lang.object" Watch "java.lang.object" New topic


Kota li

Joined: Sep 05, 2007
Posts: 20
which of the following classes java.lang.Object override hashCode() method in Object class
,, ,, .StringBuffer
which of them override
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

You can find the answer by looking up the API documentation of those classes. If the documentation doesn't mention a hashCode() method, then the class doesn't override it.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Vikrant Sahdev
Ranch Hand

Joined: May 31, 2007
Posts: 58
String and Wrapper classes override equals() method. And by contract, if you override equals() method, you need to override hashCode()method as well.

StringBuffer doesnt override equal()method and therefore doesnt override hashCode()method as well.

Coming soon...
I agree. Here's the link:
subject: java.lang.object
It's not a secret anymore!