The rule about the equals and hashCode implementations is the following : ( a.equals(b) ) implies ( a.hashCode() == b.hashCode() ).
In this example, B is not a correct answer because using only "a" as hashCode value doesn't fullfil the condition above if the two ValuePair instances are equals because (VP1.a == VP2.b) && (VP1.b == VP2.a). VP1.a and VP2.a can be different in that case, and the rule would be broken.
got it.Thanks a lot Gilles.I hv worked it out using this sample objects
here as per equals method objects (1,2) and (2,1) are treated as equal objects but both are placed into different buckets with numbers 1 and 2 respectively.Since equal objects must be placed in same buckets this is a contradictions.