Abstraction/Interface

The name of a method and the list of its parameter types is called a method signatureIt describes how the behavior of an object (of Car or Truck, in our example) can be accessed. Such a description together with a return type is presented as an interface. It does not say anything about the code that does calculations—only about the method name, parameters types, their position in the parameter list, and the result type. All the implementation details are hidden (encapsulated) within the class that implements this interface.

As we have mentioned already, a class can implement many different interfaces. But two different classes (and their objects) can behave differently even when they implement the same interface. 

Similarly to classes, interfaces can have a parent-child relationship using the extends keyword too:

interface A { }
interface B extends A {}
interface C extends B {}
interface D extends C {}

In this code, the interfaces A, B, C, and D have the following relationships:

All non-private methods of interface A are inherited by interfaces B, C, and D

Abstraction/interface also reduces dependency between different sections of the code, thus increasing its maintainability. Each class can be changed without the need to coordinate it with its clients, as long as the interface stays the same.