Given: What is the result?
A.
Compilation fails
B.
An exception is thrown at runtime
C.
There is no result because this is not correct way to determine the hash code
D.
Hash is: 111111, 44444444, 999999999
Given: What is the result?
A.
Compilation fails
B.
An exception is thrown at runtime
C.
There is no result because this is not correct way to determine the hash code
D.
Hash is: 111111, 44444444, 999999999
Why compilation fails in this ?
Regards,
Sanket Patel
@Sanket Patel :
Because Overriden methods (getHash) cannot return a different type.
Parent class : int getHash()
child class : long getHash()
(Except for object type returns if child method returns child of the parent returned type)