Custom Search

Monday 27 August 2012

Java Program to explain Super Keyword, write a program in java using super keyword through extend class of class inheritance


Java Program to explain Super Keyword, write a program in java using super keyword through extend class of class inheritance

Program
class base
{
int i;
base(int a)
{
i=a;
}
void show()
{
System.out.println("Base:"+i);
}

}
class derived extends base
{
int i,j;
derived(int a,int b,int c)
{
super(a);
i=b;
j=c;
}
void show()
{
super.show();
System.out.println("Base i:"+super.i);
System.out.println("Derived i:"+i);
System.out.println("Derived j:"+i);
}

}
class superEx
{
public static void main(String args[])
{
derived d = new derived(10,20,30);
d.show();
}
}

No comments:

Post a Comment

Laptops