Categories
Uncategorized

Super keyword

Use of super keyword in a constructor

class employee

{

     String name;

     int empid;

     employee()

          {

               name=”pritam”;

               empid=001;

               System.out.println(“Name:”+ name + “\nempid:”+ empid);

            }

}

class address extends employee

{

    String addr;

    address()

         {

             super();

             addr=”Bangalore”;

             System.out.println(“address:”+ addr);

          }

}

class salary extends address

{

     int sal;

     salary()

            {

                super();

                sal=10000;

                System.out.println(“Salary:”+ sal);

            }

}

class empinfo

{

    public static void main(String args[])

          {

             salary s=new salary();

          }

}

Out put:

name: pritam

empid:001

address: Bangalore

salary:10000