posted 20 years ago
5. What two statements are true about *properly* overridden hashCode() and equals() methods?
A. hashCode() doesn�t have to be overridden if equals() is.
B. equals() doesn�t have to be overridden if hashCode() is.
C. hashCode() can always return the same value, regardless of the object that invoked it.
D. If two different objects that are not meaningfully equivalent both invoke hashCode(), then hashCode() can�t return the same value for both invocations.
E. equals() can be true even if it�s comparing different objects.
Answers: c,e
My doubts:
[1] What does *properly* mean ? Legal / appropriate / efficent
[2] Could someone try to explain why c,e are right? I dont quite get the explanation given in the book.
Thanks,
Cathy.