Can I force abstract methods to be protected when someone overrides them?

In my abstract class, I have something like this:

public Object methodIWantToExpose(){
  // ... 
  methodIDontWantExposed()
  // ...
}

protected abstract void methodIDontWantExposed();

The thing is, I want to force the person that extends methodIDontWantExposed() to make it protected, because I don't want the extending class to have both methodIDontWantExposed and methodIWantToExpose exposed.

Is there a way to do this (or a different approach which might avoid my problem)?

Jon Skeet
people
quotationmark

No. A subclass can always make a method more public.

Even if they couldn't do this with the method you have in your class, they could always write:

public void callsMethodIDontWantExposed() {
    methodIDontWantExposed();
}

... so you'd be in the same situation.

people

See more on this question at Stackoverflow