please explain me why " HighDrop 1" is the output following code-:
What I think is obj of Low class does not have access to drop() method of High class and "High hl" reference variable is referring to obj of class Low so it should give compile error...
Hi vishal ,Here in this code jvm will invoke method of your reference variable not of the subtype object's method ,it decides at compile time that it has to invoke reference variable's method and your method in subclass is also private, so it is redefining that method not overloading or overriding it.
shiva mistry wrote:Hi vishal ,Here in this code jvm will invoke method of your reference variable not of the subtype object's method ,it decides at compile time that it has to invoke reference variable's method and your method in subclass is also private, so it is redefining that method not overloading or overriding it.
Namaste Shiva and
Thank you !!
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
a bit of art, as a gift, that will fit in a stocking