Consider :
o1 and o2 denote two object references to two different objects of same class.
Which of the following statements are true?
Select 2 options
hashCode()
== o2.hashCode()
will always be false. Correct Options are : C D
A. is wrong.
It depends on how the equals method is overridden.
If it is not overridden, then it will return false.
B. is wrong. hashCode()
can be overridden and so the given statements is not true.
C. is a correct answer.
The == operator compares whether the two references are pointing to the same object or not.
Here, they are not, so it returns false.
D. is a correct answer.
It depends on how the class implements this method.
E. is wrong.
It will always return false if references are to two different objects.
Both equals () and hashCode()
methods can be overridden by the programmer so you can't say anything about what they will return without looking at the code.