Require override of specific methods of a non-abstract class

You would have to make your base class abstract.

public abstract class MyClass
{
    public void methodA(){} // Inherit
    public void methodB(){} // Inherit
    public abstract void methodC(); // Require override
}

You cannot require an override of a non-abstract method.

Maybe you can do something similar to the template method pattern:

 public final void methodC() { methodC1(); someMoreLogic(); methodC2();}

 protected abstract void methodC1();

 protected abstract void methodC2();

Here methodC encapsulates a fixed algorithm that calls into pieces that have to be supplied by the subclasses.


I don't think you do exactly what you want. Alternatively, create MyBaseClass as an abstract class with methodC() abstract implementations for methodA() and methodB(). Derive MyClass from it, adding an implementation for methodC(). Any classes that you do not want to have inherit that implementation should directly subclass MyBaseClass rather than MyClass.