What is an Interface?

An Interface is a group of related methods that multiple objects have in common. These methods define how the objects interact with the outside world.

When would you use an interface instead of an abstract class? Here are a few differences between the two:

  1. Superclasses represent an is-a relationship, whereas interfaces represent an -able relationship.
  2. Classes can implement multiple interfaces, but may only extend one class.
  3. Abstract classes can provide default behavior for a method/constructor, whereas interfaces can't.
  4. Methods are required to be implemented from an interface; if you add a new method to your interface, you have to add an implementation to every object that uses that interface.