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
D
D check explanation here:
http://www.aiotestking.com/oracle/what-is-the-result-302/
I meant A
A
a
tested
Answer: A
Explanation:
Method getHash() in SampleClass is of type int and both SampleClassA and SampleClassB are extending the SamleClass and overriding the method getHash(). But in the child classes the return type is declared as long. The program will not compile because the return type of the child is incompatible with return type of the parent.
A
The compilation fails as SampleClassA and SampleClassB cannot override SampleClass because the return
type of SampleClass is int, while the return type of SampleClassA and SampleClassB is long.