The Purpose of Java Interfaces

The Purpose of Java Interfaces

Previous Home Next

 

In Java,problem of multiple inheritance is solved with a powerful construct called interfaces. 

Interface can be used to define a generic template and then one or more abstract classes to define partial
 implementations of the interface.

Interfaces provide a standard framework for accessing classes.

 Interfaces just specify the method declaration (implicitly public and abstract) 
and can only contain fields (which are implicitly public static final).
 
Interface definition begins with a keyword interface. An interface like that of an abstract class cannot instantiated.

 Once a class implements an interface, the Java compiler knows that an instance of the class will contain the 
specified set of methods


 

Previous Home Next