Site hosted by Angelfire.com: Build your free website today!
 

Interface

An interface defines a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. An interface defines a set of methods but does not implement them. A class that implements the interface agrees to implement all the methods defined in the interface, thereby agreeing to certain behavior.

Differences interface and abstract class:

  • An interface cannot implement any methods, whereas an abstract class can.

  • A class can implement many interfaces but can have only one superclass.

  • An interface is not part of the class hierarchy. Unrelated classes can implement the same interface.