Interface v.s. Functional Interface
J Fowler

J Fowler @johnscode

About: Technologist, Software Development Lead/Manager, early IoT developer

Location:
US
Joined:
Oct 20, 2023

Interface v.s. Functional Interface

Publish Date: Jun 29 '24
2 1

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.

Comments 1 total

  • Prateek Sharma
    Prateek SharmaJan 3, 2025

    Thank you for this post :) . It really increased my knowledge about the key difference about them and also about where to use them.

Add comment