I am having a scenario where there are several subclasses which have got similar implementations and some extra methods for which the implementations differ with each subclass. I assume that an abstract class would be a good choice for this scenario. But would it be better if that abstract class implements an interface which contains all method declarations.Or should I just stick with the abstract class instead.
In short, I would like to know the scenarios where I should prefer Abstract classes at the top of the hierarchy rather than an Interface.
Use the abstract class if your subclasses have is-a relationship with the abstract class.
You can have both an abstract class and an interface – the abstract class specifying implementations, and the interface specifying the API.
The collections frameworks is an example of that – it has
ArrayList extends AbstractList implements List