Basic Interview Questions
When to use interface or abstract?
Interface
1. Go for interface when you expect that unrelated classes will implement this. For example: Serializable
2. You want to specify the behaviour of a particular data type, but not concerned about who implements its behaviour.
Abstract
1. You want to share code among several closely related classes.
2. You expect that classes that extend your abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private).
3. We use abstract classes when we want to commit the programmer (either oneself or someone else) to write a certain class method, but we are only sure about the name of the method, and not the details of how it should be written.