Why should we use Interface in java?

By default all variables are static final variables
By default all methods are abstract methods

Interface having only abstract methods

The class which is going to inherit from the interface that class should provide implementation to all abstract methods.

Why use Interface?


There are mainly three reasons to use interface. They are given below.

It is used to achieve fully abstraction.
By interface, we can support the functionality of multiple inheritance.
It can be used to achieve loose coupling.

No comments:

Post a Comment