Saturday, 2 June 2012

super keyword with example

super keyword


the main use of the the super keyword is to enable the subclass to refer its super class

the main two use of this super keyword is given below


  • used to access the super class constructors.
  • used to access the methode variable


Example program


  public class a
{
public void show()
{
system.out.println("class a");
}
}
public class b
{
public void show()
{
super.show();
system.out.println("class b");
}
class c
{
public static void main(string args[])
{
b ob1=new b();
ob1.show();
}
}


output


class a
class b



1 comment: