Looking at great example Polymorphism vs Overriding vs Overloading , consider this scenario:
abstract class Human {
public void goPee() {
println("drop pants");
}
}
class Male extends Human {
public void goPee() {
super.goPee();
println("stand up");
}
}
class Female extends Human {
public void goPee() {
super.goPee();
println("sit down");
}
}
My questions:
Is it possible, on concrete classes level, to enforce using super.goPee() inside goPee() ? if so - how ?
Is it possible, on abstract class level, to know which concrete class had called super.goPee() ? Rationale for that is if I would need to call method let's say
liftToiletSeat()
somewhere on abstract class level.
Thank you.