Yes, a functional interface can extend another interface, provided that the resulting interface still contains only one abstract method. If extending another interface introduces more than one abstract method, the interface will no longer qualify as a functional interface.
Key Points: • A functional interface must have exactly one abstract method. • It can extend one or more interfaces if the single abstract method rule is maintained. • Default and static methods do not affect functional interface status. • If multiple inherited abstract methods create ambiguity, the interface is no longer functional. • The @FunctionalInterface annotation helps the compiler validate this rule.
Example: A functional interface can inherit an abstract method from its parent interface and still remain functional.
Code Example:
interface Printable {
void print();
}
@FunctionalInterface
interface Document extends Printable {
}
public class Demo {
public static void main(String[] args) {Document document = () ->
System.out.println("Printing Document");
document.print();
}
}Output:
Printing Document
Valid Functional Interface with Default Methods:
interface Vehicle {
void start();
default void stop() {
System.out.println("Vehicle Stopped");
}
}
@FunctionalInterface
interface Car extends Vehicle {
}This is valid because there is still only one abstract method: start().
Invalid Example:
interface Printable {
void print();
}
interface Scannable {
void scan();
}
@FunctionalInterface
interface MultiFunction extends Printable, Scannable {
}Compilation Error:
Unexpected @FunctionalInterface annotation
This interface inherits two abstract methods, so it is no longer a functional interface.
Special Case:
If multiple parent interfaces declare the same abstract method signature, the child interface can still be functional.
Example:
interface A {
void display();
}
interface B {
void display();
}
@FunctionalInterface
interface C extends A, B {
}Since there is only one effective abstract method, C remains a valid functional interface.
Benefits:
• Promotes interface reuse • Supports lambda expressions • Enables flexible API design • Allows combining behaviors while preserving functional interface rules
Interview Tip: A concise interview answer is:
"Yes, a functional interface can extend another interface as long as the total number of abstract methods remains one. Default and static methods do not affect this rule, but if multiple inherited abstract methods exist, the interface will no longer be considered a functional interface."