In Java which one to use Abstract Class or Interface ?

#1
- Use Abstract Class if you're sure that there can be more specialized subclasses of Abstract Class and there is really a logic is a relationship.

- Dont use Abstract Class just for code reuse.

- Use Interface to encapsulate behaviour and let concrete subclasses to implement that behaviour.

- An alternative approach could be to use Abstract Class to have common implementation and for the behaviour which is gonna very use composition for the varying behavior.
 
#2
Java doesn't accept assorted inheritance; thus, you cannot accept a chic that accouterments two abstruse classes at once. ... An interface is bigger than a abstruse chic back you demand assorted classes to apparatus that interface and back you don't accept to accede absence behavior.
 
Top