Why doesn't SubClass need to implement the doFoo () method?
Because it is already implemented in SuperClass .
But I cannot add @Override for the doFoo () method in SuperClass.
No, you cannot, because SuperClass does not implement AnInterface . It does not cancel any method.
So is it shaded?
No. Tenerization is something else. This applies to variables. So, if SuperClass has a varaible foo , and in SubClass you are trying to define a variable with the same name that will obscure. It has no name.
And is this a good / normal practice?
This is a common practice. I have seen this several times in many large projects.
TL; DR An example follows :
Let's say we have the interface needed to implement ModelBasedWizard (a wizard is a common thing in many desktop applications).
public interface IModelBasedWizard { public void addWizardPage(IWizardPage page); public IStatus getWizardStatus(); public void bindModel(IModel model); }
Say that there is already an implementation of the Wizard
public class Wizard { public void addWizardPage(IWizardPage page) { pages.add(page); page.createContent(this); } public IStatus getWizardStatus() { List<IStatus> stati= new ArrayList<Status>(); for (IWizardPage page : pages) { stati.add(page.getStatus()); } return stati; } }
Now this is just the visual part of the Wizard, but she knows nothing about the model. Okay, no problem:
public class ModelBasedWizard extends Wizard implements IModelBasedWizard {
source share