constructor calling sequence.
Hi.
I have a doubt in following code.
class Super
{
Super(int x)
{
System.out.println(x);
}
}
class Sub extends Super
{
Sub(int k)
{
super(k);
System.out.println("Inside sub class");
}
}
class Main
{
public static void main(String []args)
{
Sub obj = new Sub(5);
}
}
We have been told that before sub class constructor super class constructor runs.And if that does happen how come sub class constructor is supplying parameter to super class constructor.Also if we skip the whole constructor of sub class then compiler flashes error.
Please help.
THanks.