Having these abstractions implemented as interfaces allows more flexibility.
Interfaces allow programmers to use multiple inheritance of type in Java. This way you can treat any class as an instance of the interface regardless of its inheritance hierarchy.
You can implement any number of interfaces in a single class but you can only have a single superclass (as expressed by the extends
keyword).
At the same time, nothing prevents you from providing a skeletal implementation of any given interface
. Just write an abstract class
implementing it and use it as you please. You still have a single place to put the common parts and you don't make the clients of your API dependent on any actual implementation.
Besides, lists can have vastly different implementations and the details of the core behaviours can rely on mechanisms that are not at all similar.
Take a look at LinkedList
and ArrayList
for example.
The first one is backed by a number of interlinked objects. The latter stores its elements in an array. The way you access elements of these data structures is simply different. The effect of these operations is identical (and understandably, both these collections implement the List
interface) but the actual behaviour, the algorithms used to perform those operations are not really common.
Coincidentally, these concrete classes also have abstract
superclasses that serve as their skeletal implementations. LinkedList
is an instance of List
and AbstractSequentialList
while ArrayList
is a List
and an AbstractList
List
is an interface because of how general it is. It does not assume anything about implementation. AbstractSequentialList
and AbstractList
on the other hand do assume certain ways of element access. Hence they're implemented as abstract classes.
In response to the very beginning of your question
While defining the hierarchy, one can think to embed the abstract method(behaviour) in abstract class only because the derive concrete class posses that as core behaviour with it's specific implementation, one can think to embed the abstract method(behaviour) in interface only because derived concrete class does not posses that as core behaviour(but as peripheral) having it's specific implementation.
Above definition can be understood well with this example
One of the good reference also supports this point:

It's true that implementing multiple interfaces in a single class allows you to combine possibly unrelated sets of behaviour, or as you express it, peripheral behaviour but this is just a use case rather than the purpose of interfaces in its entirety.
Using interfaces to create mixins is a great use case for them and the only way to have multiple inheritance in Java but you're free to use interfaces outside this context.
It's perfectly valid to use an interface to define a set of core behaviours for a family of classes. In this case, I wouldn't say it is used as a mixin. It just defines a contract. At the same time, it can be used as a mixin by any other class if the programmer so desires. This is a matter of naming and the context in which you use these concepts.
The distinction between core and peripheral behaviour is completely separate from the distinction between classes and interfaces. What truly makes the difference here is that the set of implemented interfaces specifies what you can do with an object while the classes (abstract or not) in its inheritance hierarchy define how these things are to be done.
An abstract class with all its methods declared as abstract is just like a poorly implemented interface with its usage severely limited by the lack of capability regarding multiple inheritance of type.
Queue
as well? ALinkedList
is both, but it can't have double inheritance! – Ordous Nov 13 '14 at 18:40What specific behaviour would an array-backed list and a linked list have that is the same in implementation?
, am not sure, why the implementation of array-backed list and linked list will be same(for example, insertFront() say)?, they will be different but for same behaviour name(i.e., insertFront()). for your second question: Yes,Queue
should be an abstract class` if it has its own core behaviour. ifLinkedList
is trying to inherit core behaviours of both super typesList
andQueue
then that is meaningless. – overexchange Nov 13 '14 at 18:58ArrayList
andLinkedList
is different. Am still not clear, How same/different implementation related to usage ofabstract class
? Because i would just declare aspublic abstract boolean insertFront();
in my abstract class and implement it differently in multiple subclasses? – overexchange Nov 13 '14 at 19:05