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:
line 1 - 6
.line 5
a method is declared.
This method must be declared in each class that implements the interface.line 8 and 17
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.