Interface Exercise
Interface Exercise
The Hovercraft class shown in the diagram inherits from both LandVehicle
and SeaVessel since the hover-craft is in the rather unique position of being
able to travel on land and sea. The Hovercraft class cannot be expressed in
Java since Java does not have the facility for multiple inheritance in classes.
All other classes in the diagram use only single inheritance and so they can
be expressed in Java.
Questions:
1. Write an interface IsEmergency which extends no other interface and
contains just one method soundSiren which takes no arguments and
returns no value.
2. Write a class PoliceCar that implements the IsEmergency and
IsLandVehicle interfaces.
3. In addition to the methods you have written for the PoliceCar class,
think of a new method or property that police cars have and add it to
the class.