Search⌘ K

Interfaces

Explore Java interfaces and their role in object-oriented programming. Understand how interfaces define method contracts without implementation, enabling 100% abstraction. Learn the rules for interface declaration and how classes use interfaces to achieve multiple inheritance and loose coupling in your Java code.

What is an interface?

An interface is just like a class and specifies the behavior that a class must implement.

An interface can be used to achieve 100% abstraction as it contains the method signatures/abstract methods(what to be done) and no implementation details (how to be done) of these methods. In this way, interfaces satisfy the definition of abstraction. The implementation techniques of the methods declared in an interface are totally up to to the classes implementing that interface.

An interface can be thought of as a contract ...