Java: Prevent subclass from providing a different interface than base class
<p>Is there a means to prevent a subclass from exposing public methods other than those defined in the base class, at compile-time?</p>

<p>For example:</p>

<pre><code>abstract public class AClass {

   abstract public void anAllowedMethod();

}

public class BClass extends Aclass {

    public void anAllowedMethod() {

    }

    public void anAdditionalNonAllowedMethod() {

    }

    private void thisMethodIsAllowedBecauseItsNotPublic() {

    }

}
</code></pre>

<p>Perhaps there is some keyword I can use in AClass to declare the subclass can only implemented the methods defined in AClass (ie. "anAllowedMethod()")?</p>
