Assume that class A extends class B, which extends class C. Also all the three classes implement the method test(). How can a method in a class A invoke the test() method defined in class C (without creating a new instance of class C).
The answer to this question given at source is that it is not possible ,i am not able to understand why.I read the docs:https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
Suppose we have a class Animal(class C), and class Canine(class B) extends it and class Dog(class A) extends Canine(class B).so if i want to invoke a method test() in class c why cant i do it?? According to inheritance when A extended B class it has all the methods of B as well as of C.Right?
Another example:
public class MountainBike extends Bicycle {
// the MountainBike subclass adds one field
public int seatHeight;
// the MountainBike subclass has one constructor
public MountainBike(int startHeight,
int startCadence,
int startSpeed,
int startGear) {
super(startCadence, startSpeed, startGear);
seatHeight = startHeight;
}
// the MountainBike subclass adds one method
public void setHeight(int newValue) {
seatHeight = newValue;
}
}