Amazon Interview Question
Software Engineer / DevelopersI think the primary reason for making a choice between inheritance and interface is to make the distinction of having default behavior of the object.
In inheritance, the child class extends the parent class's behavior as the default and this is the case for all other subclasses of that parent class.
In interface, you are simply defining a common set of operations that may be entirely different depending on the implementation.
Interface should be preferred over inheritance because interfaces increase code reusibility, decreases coupling and reduces the chances of breaking of sublasses dude to change in superclass
- ashwini manny August 14, 2009