Program to illustrate the super() feature.

class X
{ int i;
X(int i)
{ this.i =I;}
}
class Y extends X
{ int j;
Y(int i, int j)
{ super(i);
this.j=j; }
}
class XYdemo
{
public static void main(String[] args)
{
Y y1 = new Y(11,12);
System.out.println(“ Value of i in class Y is “ + y1.i);
System.out.println(“ Value of j in class Y is “ + y1.j); } }

Output is
Value of i in class Y is 11
Value of j in class Y is 12

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.