abstract class Animal {
public void test1() {
System.out.println(" Animal test1");
test2();
}
public void test2() {
System.out.println(" Animal test2");
}
}
class Cat extends Animal {
@Override
public void test2() {
System.out.println(" Cat Test2 ");
}
}
public class MyClass {
public static void main(String [] args) {
Animal a = new Cat();
a.test1();
}
}
So,
why the first call is to test1 method of Animal class ? and, why test2() method call from test1() method resolves to test2() method of child class ?
I tried to understand from Call method from another method in abstract class with same name in real class, but could not understand much.