Invoking Overriding Method:-
A sub-class method can invoke a super-class method using the super keyword. In the following code, line 14 invokes the parent class method showDetails().
Invoking Overriding Methods Program:-
class Employee{
public String name = ”Mahmud”;
public float salary = 50000;
public void showDetails(){
System.out.println(name+” ”+salary);
}
}
public class Manager extends Employee{
public String department = ”Engineering”;
public void showDe tails(){
super.showDetails();
System.out.println(” ”+department);
}
public static void main(String[]args){
Manager m = new Manager();
m.showDetails();
}
}
A sub-class method can invoke a super-class method using the super keyword. In the following code, line 14 invokes the parent class method showDetails().
Invoking Overriding Methods Program:-
class Employee{
public String name = ”Mahmud”;
public float salary = 50000;
public void showDetails(){
System.out.println(name+” ”+salary);
}
}
public class Manager extends Employee{
public String department = ”Engineering”;
public void showDe tails(){
super.showDetails();
System.out.println(” ”+department);
}
public static void main(String[]args){
Manager m = new Manager();
m.showDetails();
}
}
I appreciate you sharing this article. Really thank you! Much obliged.
ReplyDeleteThis is one awesome blog article. Much thanks again.
sap online training
software online training
sap sd online training
hadoop online training
sap-crm-online-training