Which code, when inserted at (1), in the equalsImpl()
method will provide a correct implementation of the equals()
method?.
public class Pair { int a, b;//w ww . j a va 2 s . c om public Pair(int a, int b) { this.a = a; this.b = b; } public boolean equals(Object o) { return (this == o) || (o instanceof Pair) && equalsImpl((Pair) o); } private boolean equalsImpl(Pair o) { // (1) INSERT CODE HERE ... } }
Select the three correct answers.
(b), (d), and (e)
(a) and (c) fail to satisfy the properties of an equivalence relation.
(a) is not transitive and (c) is not symmetric.