It is a keyword in java used to access members of a class inherited by the class in which it appears. Super method is use to transfer the message or data to their super class (it refers to a class from which a particular class (subclass) is derived.) constructor to initialize their data.
Example
this is the simple demonstration, how to use super keyword in java.Class Person
{
String name,address;
int age;
Person(String userName,String add, int userAge)
{
name=username;
address=add;
age=userAge;
}
void show()
{
System.out.println(name);
System.out.println(address);
System.out.println(age);
}
}
Class Employee extends Person
{
int empCode,empSal;
Employee(String name, String add, int u_age,int code,int sal)
{
Super(name,add,age):
empCode=code;
empSal=sal;
void show1()
{
show();
System.out.println(code);
System.out.println(sal);
}
Public Static void main(Strings args[])
{
Employee e=new Employee(“davis”,”newHoles”,27,001,4000);
e.show1();
}
}
Anonymous User
23-Apr-2019Thanks for sharing.
Samuel Fernandes
25-Jul-2017Thanks for sharing informative post.