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();
}
}