Java program for super keyword(Access hidden variable of the super class)

 class A

{

 int i,j;

 void SetVal(int p,int q)

 {

  i=p;

  j=q;

 }

 void show()

 {

  System.out.println(i+" "+j);

 }

}

class B extends A

{

 int i,j;

 void SetVal(int p,int q,int r,int s)

 {

  i = p;

  j = q;

  super.i = r;

  super.j = s;

 }

 void display()

 {

  System.out.println(i+ " "+j+" "+super.i+" "+super.j);

 }

}

class Super1a

{

 public static void main(String ar[])

 {

  B ob = new B();

  ob.SetVal(30,40,50,60);

  ob.display();

 }

}

OUTPUT






Comments