Inside Interfaces only methods can be defined.
The methods don't have body and must be declared in the classes that implement the interface.
Defining interfaces:
Implementing interface:
Output:
Explanation:
lines 5 - 10
.line 9
a method is declared.
This method must be declared in each class that implements the interface.line 12 and 21
the classes
Car
and Bicycle
implement the interface.
For this reason they must define the function getInsuranceCost
.
If this is not done then the code won't compile.