Exams Knowledge Hub

MCQs for Competitive Exams, School & College Exams

Module: | Classes, Objects, OOPs & Inheritance

Q33: Consider the following statements regarding Functional Interfaces in Java:

1. A Functional Interface is strictly defined as an interface that contains exactly one abstract method, commonly referred to as a Single Abstract Method (SAM).
2. If an interface contains exactly one abstract method but additionally includes several 'default' and 'static' methods, it immediately loses its Functional Interface status and cannot be used with lambda expressions.
3. The @FunctionalInterface annotation is a mandatory compiler directive; omitting it will cause the compiler to permanently reject the interface from being evaluated as a target for lambda expressions.

Which of the above statements is/are correct?
A
Only 1
B
Only 1 and 2
C
Only 1 and 3
D
1, 2, and 3
✅ Correct Answer: A
🎯 Quick Answer:
The correct statement is 1 only. Statement 2 is incorrect because default and static methods have bodies; therefore, they do not count toward the one-abstract-method limit. Statement 3 is incorrect because the @FunctionalInterface annotation is entirely optional, acting merely as a safeguard rather than a strict requirement.
Concept Definition: Functional Interfaces are the foundational bridge between Java's Object-Oriented architecture and functional programming paradigms.
They serve as the strict data type target for all Lambda Expressions.
Structural Breakdown: A Functional Interface must have exactly one abstract method (e.g., java.lang.Runnable only has run()). Standard examples include Predicate (test()), Consumer (accept()), and Supplier (get()). Historical/Related Context: Introduced in Java 8, Functional Interfaces revolutionized the language by allowing developers to pass behavior (functions) as arguments to methods.
Instead of creating a massive anonymous inner class just to execute a single line of code inside a thread, developers could pass a sleek, one-line Lambda expression.
Causal Reasoning: The compiler can implicitly recognize any interface with exactly one abstract method as a Functional Interface.
The optional @FunctionalInterface annotation exists purely to prevent human error; if another developer accidentally attempts to add a second abstract method to the interface later, the annotation triggers an immediate compiler failure to protect the existing Lambda ecosystem.