11 Using Interfaces

 

After reading lesson 11, you will be able to:

  • Understand the definition of an interface
  • Create new interfaces
  • Implement an interface

This lesson introduces the topic of interfaces in Java.  An interface is considered a reference type in Java and serves several purposes.  It acts as a rule or contract for any code that implements the interface.  All functionality identified in the interface must be implemented.  The interface contains a collection of abstract methods, constants, default methods, and static methods.  Interfaces are used for dependency injection, unit testing and play a key role in design patterns.

11.1   What is an Interface

11.2   Defining a new Interface

11.3   Implementing an Interface

11.4   Summary