The super keyword can be used to invoke an overridden method in the superclass from the overriding method in the subclass
It can also be used to invoke a superclass constructor from the subclass constructor.
public class SuperClass {
public void m1() {
System.out.println("In SuperClass");
}
}
public class SubClass extends SuperClass {
public void m1() {
super.m1();
System.out.println("In SubClass");
}
}
It can also be used to invoke a superclass constructor from the subclass constructor.
public class SuperClass {
public SuperClass() {
System.out.println("In SuperClass constructor");
}
}
public class SubClass extends SuperClass {
public SubClass() {
super();
System.out.println("In SubClass Constructor");
}
}
Hello,
ReplyDeleteA sentence in this explanation is incorrectly worded "The super keyword can you used to invoke"