Program 5: Interface Inheritance


When using interfaces with inheritance you have at least three choices:


Version 1: (Preferred)

Base class

  • implements the interface

  • declare the interface methods as MustOverride

  • interface method is just method heading

  • interface method heading DOES include "implements <interface>"

Derived class

  • does NOT implement the interface

  • declares the interface methods as Overrides

  • interface methods do NOT include "implements <interface>"

Polymorphism

  • possible


Version 2:

Base class

  • implements the interface

  • interface methods include method heading and end

  • interface method heading DOES include "implements <interface>"

Derived class

  • does NOT implement the interface

  • declares the interface methods as Shadows

  • interface methods do NOT "implements <interface>"

Polymorphism

  • possible


Version 3:

Base class

  • does not implement the interface

  • interface methods not included

Derived class

  • DOES implement the interface

  • interface methods DO include "implements <interface>"

Polymorphism

  • not possible


See also http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=337