I have 2 classes that extended from same parent class. In these classes I have method with same name but different implementation. Is there any way to call this specific method from its parent class? Please find below sample code
public class Fruit {
public String callingName () {
//calling specified method getTaste() here
// return specified value;
}
}
public class Orange extends Fruit{
private String getTaste(){
return "Orange has sour taste";
}
}
public class Banana extends Fruit{
private String getTaste(){
return "Banana has sweet taste";
}
}
In this situation, I don't have any reference either to Banana or Orange. The class Fruit itself has to decide which is the right getTaste() will be called from callingName() method. Thanks for any kind help.