class Parent
{
int a;
Parent()
{
System.out.println("This is Parent default constructor");
}
Parent(int x)
{
a = x;
System.out.println("This is Parent param constructor");
}
}
class Super extends Parent
{
int b;
Super()
{
System.out.println("This is Super(child) Default constructor");
}
Super(int z)
{
super(z); //must be the first line of this constructor..
System.out.println("This is Super(child) param constructor");
}
public static void main(String []ars)
{
Super obj = new Super(8);
Super obj1 = new Super();
}
}
{
int a;
Parent()
{
System.out.println("This is Parent default constructor");
}
Parent(int x)
{
a = x;
System.out.println("This is Parent param constructor");
}
}
class Super extends Parent
{
int b;
Super()
{
System.out.println("This is Super(child) Default constructor");
}
Super(int z)
{
super(z); //must be the first line of this constructor..
System.out.println("This is Super(child) param constructor");
}
public static void main(String []ars)
{
Super obj = new Super(8);
Super obj1 = new Super();
}
}
No comments:
Post a Comment