Given that the objects referenced by the parameters override the equals()
and the hashCode()
methods appropriately, which return values are possible from the following method?
String func(Object x, Object y) { return (x == y) + " " + x.equals(y) + " " + (x.hashCode() == y.hashCode()); }
Select the four correct answers.
(a), (b), (d), and (h)
(c) is eliminated since the hashCode()
method cannot claim inequality if the equals()
method claims equality.
(e) and (f) are eliminated since the equals()
method must be reflexive, and (g) is eliminated since the hashCode()
method must consistently return the same hash value during the execution.