Title: Interface
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: (OLDstyle) Learning Modules

Interface

An interface is a set of constants and methods that may be implemented in another class.

An interface contains the keyword interface in its declaration.

Interface fields are necessarily constants since they may only have modifiers public, static, and final.If the modifiers are omitted, they are assumed.

Interface methods are necessarily abstract since they have no implementations.

An interface is implemented in a class using keyword implements.

An interface is a contract with any class that implements it in that the class must reference and define the implementation of every interface method.

Interface field names may be used unqualified in any class that implements the interface.

Unlike a class, an interface may not be instantiated and has no constructors.

An interface may not extend a class but may extend one or more other interfaces.

implementing class has the responsibility to implement each method.

For more information, see:

Interfaces