Date Category dev Tags java

Interface

Features

  • Multiple inheritance
  • Does not provide any code
  • static final constants
  • A class implements an Interface
  • Usually describe peripheral abilities of a class

Example

An Automobile class can implement an Automatic interface.

When To Use

Usually when something in the design will change frequently, such as a file format.

Abstract Class

Features

  • Single inheritance
  • complete, default, or stubs of code to be overwritten
  • instance and static constants
  • A class extends an Abstract Class
  • Defines the core identity of it's descendants

Example

A SportsCar class can extend an Automobile abstract class.

When To Use

For planned inheritance hierarchies such as a framework or when subclasses need to provide specific behaviors.


Comments

comments powered by Disqus