This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Diff between Hashcode and equals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Diff between Hashcode and equals" Watch "Diff between Hashcode and equals" New topic
Author

Diff between Hashcode and equals

Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
Which of the following statements are true about correctly overriden hashCode() and equals() methods?

1) the equals() must return the same value as using the == operator
2) equals() and hashCode() code must return the same value.
3) If two objects are different according to equals() they will return different hashCode() values.
4) If two objects are equal according to equals() they will return the same hashCode value.

Kindly let me know the correct answer


Thanks,
Shekar
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
4


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Diff between Hashcode and equals