Why write another article on the differences between java interfaces and abstract classes? Well I’m getting used to using WordPress so thought it was a good place to start.
The key differences are –
abstract class – IS-A
interface – CAN-DO
When to use an interface and abstract class?
The advantage of an interface is that you have a contract which any class can conform to, including existing classes. The advantage of an abstract class is that you can implement and encapsulate some core logic for your application, leaving the developer to code there own implementation
You may also want to use both, for example java.util.List is the interface, and java.util.AbstractList contains a core. You can also see this approach used in frameworks