Menu

What is interface in java?

An interface is a complete abstraction, which helps us expose the methods that can be invoked by the outer world that derive the interface(subclasses). In general terms, the interface is for hiding the data.

Types of Interface


Functional interface: A interface that has only one abstract method. It may have other static and default methods. you can leave the name while implementing the name of the method because an interface contains only one abstract method.

Marker interface: A interface without any method. This is to add on some special functionality to the class so the compiler can treat that class in different ways.

Generic interface: A interface that is general like a class and has variables, methods, and constructors.

No comments:

Post a Comment