For the Java crowd, here's one that some like to use.
Explain the difference between an interface and a functional interface.
Ok let's start with what an interface is.
An interface defines a set of methods required by an implementing class. Consider it a blueprint for a class.
An interface may inherit from multiple interfaces. It may contain abstract methods, constants, static methods and default methods.
a class may implement multiple interfaces.
Ok, now what is a functional interface?
Functional interface can also be called a single abstraction interface.
A functional interface can have only one abstract method. This is the key difference to an interface.
However, a functional interface can have default methods and static methods just like a plain interface.
So, what is the point of a functional interface. The literature suggests that functional interfaces are designed to facilitate the use of lambda expressions where one may want to pass a function as an argument or return one as a result. It is said this makes code more expressive.
So there you have it.
Top comments (0)