up previous next contents
Next: Exceptions Up: Interfaces Previous: Marker Interfaces   Contents

Subsections

When to Use Interfaces

Two Important Differences Between Interfaces and Abstract Classes

  • Interfaces provide a form of multiple inheritance. A class can extend only one other class.
  • Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.

Interface or Abstract Class

  • These two differences usually direct the choice.
  • If multiple inheritance is important or even useful interfaces are used.
  • Abstract class lets you define some or all of the implementation.
  • Any major class you expect to be extended should be an implementation of an interface.


up previous next contents
Next: Exceptions Up: Interfaces Previous: Marker Interfaces   Contents