Implementing a JAVA interface

In JAVA interfaces can be implemented with abstract classes. Interfaces are used to achieve abstraction. Here is an exemplary JAVA interface implementation (syntax):

// this is an interface in JAVA
interface Person {

  public void humandVoice(); // interface method (no body)

}

For access interface methods must be implemented. This is facilitated with the implements keyword. This is in fact similar to inheritance, which is facilitated with the extends keyword.

When implementing the interface the method body must then be specified. The class implementing the interface can be referred to as implement class or implementation class.

Here is an example with such an implementation class:

// Man class implements Person interface

class Man implements Person {

  public void humanVoice() {

    // interface method body now specified in implement class

    System.out.println("Deep dark voice");

  }

}

The interface ensures that the Man class implements all methods that the Person interface requires.

It is also possible to implement multiple interfaces in JAVA.