Sobes.tech
Junior — Middle

What type of method should a functional interface in Java have?

sobes.tech AI

Answer from AI

A functional interface in Java is an interface that contains exactly one abstract method. Such an interface can be used in lambda expressions and method references.

The method type must be abstract (without implementation), and it is the only one in the interface. Additionally, the interface can contain default methods and static methods, but they are not considered abstract.

Example of a functional interface:

@FunctionalInterface
public interface MyFunction {
    void apply(); // the only abstract method
}
What type of method should a functional interface in… - sobes.tech