Course Content‎ > ‎Session 10‎ > ‎

Intro to Interfaces

What is an Interface?
An interface is a collection of method definitions (without implementations) and constant values.
Advantages of Interfaces
Interfaces are useful for:
    - capturing similarities between unrelated classes without forcing a class
    - declaring methods that one or more classes are expected to implement 
Defining an Interface

Defining an interface is similar to creating a new class. An interface definition has two components: the interface declaration and the interface body.

    interfaceDeclaration {

The definition of an interface is a definition of a new reference data type. You can use interface names anywhere in the program, like using any other type name. You cannot instantiate objects of the interface type. It doesn't have a constructor.