Java program for super keyword(to call the constructor of super class)

 class A

{

 private int i,j;

 A(int p,int q)

 {

  i=p;

  j=q;

 }

 int showi()

 {

  return i;

 }

 int showj()

 {

  return j;

 }

}

class B extends A

{

 int k;

 B(int p,int q,int r)

 {

  super(p,q);

  k=r;

 }

 void show()

 {

  System.out.println(showi()+" "+showj()+" "+k);

 }

}

class Super2

{

 public static void main(String ar[])

 {

  B ob = new B(5,6,7);

  ob.show();

 }

}


OUTPUT






Comments