<<< Why discuss inheritance, interfaces, abstract classes, and composition in one module?     Index     Contract Enforcement using Interfaces >>>

6. Interface, Inheritance, and Composition Example


  • Inheritance: Dog is-a Mammal.

  • Interface: Dog implements Nameable.

  • Composition: Dog has-a Head.

     

  • Note that Nameable interface could also be implemented by a Planet class, a Car class, etc.

  • UML example of the interface, inheritance, and composition relationships, nameable dog:

      nameable dog


<<< Why discuss inheritance, interfaces, abstract classes, and composition in one module?     Index     Contract Enforcement using Interfaces >>>