How many of the following pairs of values can fill in the blanks to comply with the contract of the hashCode()
and equals()
methods?
class Main { //w w w. j a v a2s . com @Override public int hashCode() { return ___; } @Override public boolean equals(Main o) { return ___; } }
Random()
.nextInt()
, falseRandom()
.nextInt()
, trueF.
The equals()
method in the Object class has a parameter of type Object.
An overridden version is required to have the same type.
The equals()
method in Main is an overload rather than an override.
Since there is an @Override annotation, the code does not compile.