Program
class inheritance
{
public static void main(String[] args)
{
apple a=new apple();
a.disp();
}
}
class fruit
{
String f="fruit";
public void disp()
{
System.out.println("Base Class "+f);
}
}
class apple extends fruit
{
String f="Apple";
public void disp()
{
System.out.println("Derived Class "+f);
super.disp();
System.out.println("Super Class "+super.f);
}
}
Output
class inheritance
{
public static void main(String[] args)
{
apple a=new apple();
a.disp();
}
}
class fruit
{
String f="fruit";
public void disp()
{
System.out.println("Base Class "+f);
}
}
class apple extends fruit
{
String f="Apple";
public void disp()
{
System.out.println("Derived Class "+f);
super.disp();
System.out.println("Super Class "+super.f);
}
}
Output
Comments
Post a Comment
Share this to your friends