Which of the following values can fill in the blank for the class to be correctly implemented?
class MyClass { public int hashCode(Object o) { return ; } public boolean equals(Object o) { return true; } }
Random()
.nextInt()
C.
The hashCode()
method in the Object class does not have a parameter.
The MyClass class provides an overloaded method rather than an overridden one.
Since it is not an overridden method, the contract for the Object class' hashCode()
method does not apply, and any int value can be returned.
Option C is correct.