if class C extends class B
class B extends class A
class A has a public method called add() which is overridden in both child classes B and C.How can the version A of method add() be invoked from class C?
Try to write down your own small code because of that you understood the concept easily.
Life is easy because we write the source code.....
Joined: Feb 15, 2010
but this is not what I meant.how to invoke version A of add() from class C without creating an instance of A?
say for example if I want to have a method in C that has a line " System.out.print(/*A s method add()*/);"
what Im asking is what should come in between /*...*/?
It is quite possible and I won't tell you how to do that. The reason is that a subclass "is-a" superclass; if there is a method foo() which does something in the superclass, and something different again in the superclass of that superclass, then calling super.super.foo() breaches the principle that a class behaves as if it "is-a" superclass. (and the compiler definitely won't like super.super).
So I won't tell you how it is done, just as I wouldn't tell somebody else here.