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 hashcode()... 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 "hashcode()..." Watch "hashcode()..." New topic


Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362
In some questions he has given code for equals method for which he is asking us to select most appropiate hashcode method from given choices?

how can we answer these types of questions?

can anyone explain with simple example?

SCJP5 and SCWCD1.5
Think Twice Act Wise...
anand-k jha

Joined: Dec 02, 2008
Posts: 15

Please look below example:

Hashcode always will return a fixed value for an object, so
Second method is not appropriate here.
I think this will help you.

Djonatah Stiegler
Ranch Hand

Joined: Oct 30, 2008
Posts: 32
I think you should choose the hashCode() method that uses the same variables used on the equals() method.


From Brazil
I agree. Here's the link:
subject: hashcode()...
It's not a secret anymore!