Is it possible to define a private abstract class in Java? How would a Java developer write a construct like below?
public abstract class MyCommand {
public void execute()
{
if (areRequirementsFulfilled())
{
executeInternal();
}
}
private abstract void executeInternal();
private abstract boolean areRequirementsFulfilled();
}
You can’t have
private abstractmethods in Java.When a method is
private, the sub classes can’t access it, hence they can’t override it.If you want a similar behavior you’ll need
protected abstractmethod.And
Resources :
abstractMethods