Classes, Abstract Classes, and Interfaces

 

class

abstract class

interface

Can it be instantiated? Yes No No
Can it be extended? Yes Yes Yes
Method body? Must be { … } May be { … }
Must be ";" if declared abstract.
Must be ";"
Do not declare abstract because all methods are abstract implicitly.
Instance methods? OK OK No
Static methods? OK OK No
Abstract methods? No OK All methods in interfaces are abstract implicitly.
Instance fields? OK OK No.
Static fields? OK OK Yes, but do not declare static because all fields are public, static, and final implicitly.

Notes

  1. There is no such thing as an abstract static method.
  2. There is no such thing as an abstract field.
  3. Do not declare methods in interfaces public because they are public implicitly.