I have scenario like
Here is the abstract class
abstract class A
{
public void add()
{
//do something
}
}
Here is the class that extends above abstract class
class B extends A
{
@Override
public void add()
{
//do something else
}
}
Here is the class in which I want to call both the add methods
class C
{
A a = new B();
// Calls B's add method
a.add();
// Call A's add method ???
}
How to call A’s add method???
As explained above by various people, you can’t. If we try and understand as to what you want to achieve, i guess what you need is an interface and two classes.
You end up replacing references to
Awith AddInterface.Again, it all depends on what you want to achieve.