import java.io.*;
class One
{
int a;
One()
{
System.out.println("Constructor One");
}
One(int a)
{
System.out.println("Square of "+a+ " is "+a*a);
}
}
class Two extends One
{
int b;
Two()
{
System.out.println("Constructor Two");
}
Two(int b)
{
super(1);
System.out.println("Cube of "+b+ " is "+b*b*b);
}
}
class Three extends Two
{
int c;
Three()
{
System.out.println("Constructor Three");
}
Three(int c)
{
super(3);
System.out.println("c^4 of "+c+ " is "+c*c*c*c);
}
//protected void finalize() throws Throwable
{
}
public static void main(String args[]) throws Exception
{
Three t1=new Three();
Three t2=new Three(5);
}
}
No comments:
Post a Comment