Interview Question

Functional interfaces and lambdas?

Lambdas implement functional-interface behavior using a target type.

💡 Concept ✅ Quick Revision ☕ Java

Answer

A lambda expression creates an instance of a functional interface target type. • The target type determines parameter and return compatibility. • Lambdas do not introduce a new this binding. • Captured local variables must be final or effectively final.

Example

Code
java.util.function.Predicate<String> longName = value -> value.length() > 3;
System.out.println(longName.test("Java"));
Output
true

Quick Revision

Lambdas implement functional-interface behavior using a target type.