This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
I'm not very good at Java. But somehow i feel that, there is nothing wrong with the equals comparison in option D. it doesn't break any contact of equals comparison. So, both options C and D are correct.
i think the hashcode implementation is not correct in this particular case. As per the hashCode contract:
"If two Objects are equal as according to equals method then calling the hashCode() method on each of the two objects must produce the same integer result"
this doesn't say other way round. So, i think the equals comparison is correct in both the options. And the hashCode implementation is not correct.
PLEASE CORRECT ME IF I'M WRONG.
-Aravind<br />SCJP 5.0 (91%), Preparing for SCBCD.