About Question com.enthuware.ets.scjp.v6.2.759 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ETS User

About Question com.enthuware.ets.scjp.v6.2.759 :

Post by ETS User »

The instructions on this question are less than helpful.

ETS User

Re: About Question com.enthuware.ets.scjp.v6.2.759 :

Post by ETS User »

It should be obvious that you have to provide a correct implementation of hashCode that meets the contracts of both equals and hashCode. It should be an automatic response to check for this.

The rule of thumb is that if a member is used in hashCode, it must be used in equals. The opposite is not true, however, as we see in this question.

aitorbk
Posts: 5
Joined: Sat Jan 10, 2015 10:27 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.759 :

Post by aitorbk »

I fully agree with the reply: if you use a member not used in equals, you are breaking the contract:if they are equal they should have the same hashcode, and if you use interests, they would be "equal" but with a different hashcode!!

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests