In my first attempt I chose C but according to MasterExam explanation both C and D options are the correct answers.
I think D is not correct because supposing you have two instances of class SortOf and the folowing instance variable values :
Instance #1 ------------ name : "None" bal: 1 rate :3
Instance #2 ------------ name : "None" bal: 3 rate :1
In this case will occur the situation where the equals() method will return true when comparing both instances but hashCode() will be evaluated to false, hence breaking the contract.
Can anyone please give your comments ?
Thanks.
"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
I believe that this question may have been included in the errata of the book. You can ask Bert Bates for certain about that. But I do remember a thread here about that question.