I want to throw a custom exception if override method does not call its super method explicitly. if any class extends class A and override say() method, should call super.say() forcefully to execute code written in base class method , if fails, I want to throw custom exception like super not exception
class A {
public void say() {
System.out.println("From super");
}
}
class Demo extends A {
@Override
public void say() {
//Check if user have called super.say() or not if not throw a custom exception
super.say();
System.out.println("From Child");
}
public static void main(String[] args) {
Demo d = new Demo();
d.say();
}
}