Leave a Reply 7

Your email address will not be published. Required fields are marked *


imyrta

imyrta

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.

God

God

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.