wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes equals vs hashCode (K&B Exam 6) 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 "equals vs hashCode (K&B Exam 6)" Watch "equals vs hashCode (K&B Exam 6)" New topic
Author

equals vs hashCode (K&B Exam 6)

Michal Burak
Greenhorn

Joined: Oct 05, 2009
Posts: 7
K&B Exam SCJP6 quiz 1 question 52:



My code that prints "false true" is below. Hashcodes are not equal, equals returns true. But equal objects must have equal hashcodes.
So conclusion: only "C" is the correct answer ("D" is not correct opposed to what it says in the mock exam). Am I right or do I miss something?

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Yes you are right, this is an error in the mock exam. This has been asked before too

And welcome to javaranch...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Michal Burak
Greenhorn

Joined: Oct 05, 2009
Posts: 7
Ankit Garg wrote:Yes you are right, this is an error in the mock exam. This has been asked before too

And welcome to javaranch...


Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: equals vs hashCode (K&B Exam 6)