This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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: 15047

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!