Tuesday, February 24, 2009

while extending a class constructor issues



Demo 1:
class P
{
P()
{
super();
}

}
class C extends P // valid
{
C()
{
super();
}

}

Demo 2:
class P
{
P(int i)
{
System.out.println(i);
}
}
class C extends P // in valid (there is no argument constructor)
{
C()
{

}
}

Demo 3:
class P
{
P(int i)
{
System.out.println(i);
}
}
class C extends P
{
C()
{
super(10); // valid (without super invalid)
}
}






0 comments:

Post a Comment