go to previous page   go to home page   go to next page

Could the interfaces contain several definitions of the same constant?

Answer:

No. To ensure consistency, a constant should be defined only once, in one interface.


Public Interfaces

However, it is OK if two interfaces ask for the same method. A class that implements both interfaces only needs to provide one complete method definition to satisfy both interfaces.

An interface can be made public. This is usually what is done. When a class or interface is public it must be the only public class or interface in the file that contains it. (These notes have been avoiding public classes so that the "copy paste save and run" method can be used with just one file.)

A public interface can be implemented by any class. Many graphical user interface components implement public interfaces. You must use them to work with the GUI features of Java.


QUESTION 25:

Can an interface be made private?