An interface defines behavior. For example, a Vehicle
interface might define the move()
method.
A Car is a Vehicle, but has additional behavior. For example, the Car
interface might define the startEngine()
method. Since a Car is also a Vehicle, the Car
interface extends the Vehicle
interface, and thus defines two methods: move()
(inherited) and startEngine()
.
The Car interface doesn't have any method implementation. If you create a class (Volkswagen) that implements Car, it will have to provide implementations for all the methods of its interface: move()
and startEngine()
.
An interface may not implement any other interface. It can only extend it.