This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals vs hashCode (K&B Exam 6)

 
Michal Burak
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are right, this is an error in the mock exam. This has been asked before too

And welcome to javaranch...
 
Michal Burak
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic