I have a small doubt about this reference in the following program,why the result is "I am in B",my question is how inside the super class constructor we are able to access the subclass method.
class A {
A()
{this.print();}
public void print(){
System.out.println("I am in class A");
}
}
class B extends A {
public void print() {
System.out.println("I am in class B");
}
public static void main(String args[]) {
new Stest();
}
}
See Question&Answers more detail:os