Sorry you all to not mention the source of the question.
Question explicitly says, both x and y are reference variables for two objects of class Dog.
If class Dog follows the equals the equals and hashCode contracts, and if x and y are reference variables for two Dog objects, which statements are true? (Choose all that apply)
A. If x.equals(y) is true, then x==y must be true B. If x.equals(y) is false, then x==y may be true C. If x.equals(y) is true, then x==y may be false D. If x.equals(y) is true, then (x.hashCode() == y.hashCode()) may be false. E. If x.equals(y) is false, then (x.hashCode()==y.hashCode()) may be true F. If x==y is false, then x.equals(y) must be false.
* I was not willing to type the complete question as the software does not allow to copy paste capability, what finally I had to do.
Please any one can clarify the foll statement from K&B-Overrding equals() topic.
Yeah it is fine! It means if two reference variables refer to the same object on the heap, they will have same hashCode and identical bit information. So if they hold identical bits they are ==, means referring to the same object on the heap hence == returns true.
Yeah my above answers are correct only. the problem is with operator precedence i think when I kept comparisons in () it is giving correct results what I expected. it should be + will have more precedence than ==.
If I am wrong please let me know what is the point there.
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?