I think the reader should assume proper implementation of the hashCode method. If you are assuming improper implementations, then this question would also be false: "The equals() method can be used to test the equality of two objects, true or false."
The answer should be true, even though a bad implementation of equals would return false.
About Question com.enthuware.ets.scjp.v6.2.758 :
Moderators: Site Manager, fjwalraven
-
- Posts: 5
- Joined: Thu Apr 19, 2012 2:18 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.758 :
Yes, the reader should assume a proper implementation and even with the proper implementation you cannot use hashCode() to test for equality but you can use it to test for inequality. The explanation explains why in detail.
-
- Posts: 5
- Joined: Fri Oct 11, 2013 11:21 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.758 :
I understand "testing for inequality" this way: The test should return true if and only if the objects are not equal.
But this is actualy not the case here: There may be objects which are not equal but their hashcodes are identical.
So I think the question is not precise, you can use the hashCode() method for finding SOME, but not ALL objects which are not equal to each other!
But this is actualy not the case here: There may be objects which are not equal but their hashcodes are identical.
So I think the question is not precise, you can use the hashCode() method for finding SOME, but not ALL objects which are not equal to each other!
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.758 :
You are right. This question is not too clear and should be fixed. Thank you for your feedback!
Who is online
Users browsing this forum: Bing [Bot] and 2 guests