K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
binay shah wrote: instead D should be correct because equals method is not correctly overridden.
Can anyone explain this to me? thanks in advance.
My one regret in life is that I am not someone else.
- Woody Allen
binay shah wrote:
C. It's possible for such keys to find the correct entries in the Map.
I don't understand why C is correct. According to me, instead D should be correct because equals method is not correctly overridden.
Can anyone explain this to me? thanks in advance.
David Samer wrote:Hello, everyone, going to step in in order to ask for a doubt
Something I don't understand yet, as solution says :
E. As it stands, the Chilis class legally supports the equals() and hashCode() contracts.
Is this correct besides it has not been overriden hashCode()? (Just equals). Being a Map doesn't need for override both, equals() and hashCode()? . What am I missing? :S
Thanks in advance .
My one regret in life is that I am not someone else.
- Woody Allen
David Samer wrote:Hello, everyone, going to step in in order to ask for a doubt
Something I don't understand yet, as solution says :
E. As it stands, the Chilis class legally supports the equals() and hashCode() contracts.
Is this correct besides it has not been overriden hashCode()? (Just equals). Being a Map doesn't need for override both, equals() and hashCode()? . What am I missing? :S
Thanks in advance .
Himai Minh wrote:
Is it possible to have two Chilis instance with different unique hashcodes, but they are the same objects? No. I don't see this from the code.
David Samer wrote:
Hello there Himai
Himai Minh wrote:
Is it possible to have two Chilis instance with different unique hashcodes, but they are the same objects? No. I don't see this from the code.
Is it possible? Wouldn't be the same instance due equals and inherited hasCode()?
Then, mainly because hashCode() is inherited from Object class, it means it fulfills its contract?
Thanks in advance
My one regret in life is that I am not someone else.
- Woody Allen
David Samer wrote:
Himai Minh wrote:
Is it possible to have two Chilis instance with different unique hashcodes, but they are the same objects? No. I don't see this from the code.
Is it possible? Wouldn't be the same instance due equals and inherited hasCode()?
Then, mainly because hashCode() is inherited from Object class, it means it fulfills its contract?
Thanks in advance
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |