Look at this example...
class Super{
public Super() //1
{
a();
}
void a() //1
{
method();
}
void method() //3
{
System.out.println("1");
}
}
public class Subclass1 extends Super{
public Subclass1()//4
{
a();
}
public void method() //5
{
System.out.println("2");
}
public static void main(String []args) {
Super c = new Subclass1(); // 4 - 1 - 3
}
}
The output of this prog is 2 2
I thought it should be 1 2
how this works?
Super c = new Subclass1(); // 4 - 1 - 3
after this line control will go to super class constructor. and then method a() at 1 and then call to method at 3. but it does not work that way
pls explain...