Interfaces , Exercises

A

Show that variables in an interface are implicitly public, static, and final.

B

Create an interface with three methods getA(), getB(), and getC() in a package. Implement the interface in a class in a different package.

C

Show that all methods in an interface are automatically public.

D

Create three interfaces each with a single method. Create a new (fourth) interface that inherits from the three first interfaces and that adds a single method. Create a new class that both implements the new interface and inherits from another class. In the new class, write four methods that each takes a single formal argument of the interface type created. Create an object of the new class in a main method and show that this object can be given as argument to the four methods defined on the class.

Extra Assignments

E1

Use the four interfaces from Exercise D. Create a new abstract class that implements all these interfaces but does now provide a method body for one of the methods defined in an interface. Create another concrete class that inherits from the abstract class.