Is there a means to prevent a subclass from exposing public methods other than those defined in the base class, at compile-time?
For example:
abstract public class AClass {
abstract public void anAllowedMethod();
}
public class BClass extends Aclass {
public void anAllowedMethod() {
}
public void anAdditionalNonAllowedMethod() {
}
private void thisMethodIsAllowedBecauseItsNotPublic() {
}
}
Perhaps there is some keyword I can use in AClass to declare the subclass can only implemented the methods defined in AClass (ie. "anAllowedMethod()")?