What are implementation inheritance and interface inheritance?Implementation inheritance:
- It is achieved when a class is derived from another class in such a way that it inherits all its members. - It is called as Class Inheritance. - In this, it uses 'extends' keyword in Java. - It uses 'IS A' relationship. - The subclass is tightly coupled with superclass. - If there is any changes to superclass will break the whole relationship.
Interface inheritance:
- It is achieved when a class inherits only the signatures of the functions from another class. - It is called as Type inheritance and also called as subtyping. - In this, it uses 'implements' keyword in Java. - It is used for code reuse and polymorphism. - It uses 'HAS A' relationship, there is no IS A relationship. - It reduces coupling and implementation dependencies.
|