Leave a Reply 2

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


Sanket Patel

Sanket Patel

Why compilation fails in this ?

Regards,
Sanket Patel

bob

bob

@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)