Interfaces Blog Posts

Interfaces in Java

Interfaces :
An interface in java is a blueprint of a class. It has static constants and abstract methods.The interface in Java is a mechanism to achieve abstraction  and multiple inheritance in Java.
Like a class, an interface can have methods and variables, but the methods declared in interface are by default abstract (only method signature, no body).
To declare an interface, use interface keyword. It is used to provide total abstraction.
Interfaces specify what a class must do and not how. It is the blueprint of the class.
An Interface is about capabilities like a Player may be an interface and any class implementing Player must be able to (or must implement) move(). So it specifies a set of methods that the class has to implement.
If a class implements an interface and does not provide method bodies for all functions specified in the interface, then class must be declared abstract.

0 Likes 1131 Views