Course contentsShow
← Java
Lesson 498 of 2,87012. Abstract Classes and InterfacesFree lesson

Interface Method Name Conflicts

Understand what happens when multiple interfaces declare methods with identical signatures and how Java resolves them.

Interface Method Name Conflicts

You'll learn: What happens when multiple interfaces declare methods with identical signatures and how Java resolves them.


When a class implements multiple interfaces, you might encounter a situation where two or more interfaces declare methods with the same name and signature. This is called a method name conflict.

The Simple Case: Identical Signatures

If multiple interfaces declare methods with exactly the same signature (name, parameters, and return type), there's no conflict at all. Java treats them as a single method contract:

interface Printer {
    void print();
}

interface Display {
    void print();
}

class Screen implements Printer, Display {
    @Override
    public void print() {
        System.out.println("Printing...");
    }
    // One implementation satisfies both interfaces!
}

The Screen class only needs one print() method to fulfill both contracts. Both interfaces are satisfied simultaneously.

The Problem Case: Same Name, Different Return Types

Conflicts arise when interfaces declare methods with the same name and parameters but incompatible return types:

interface ReportGenerator {
    String generate();
}

interface DataProvider {
    int generate();
}

// This will NOT compile:
// class Reporter implements ReportGenerator, DataProvider {
//     // Can't override generate() with both String and int!
// }

Java cannot resolve this conflict. You cannot implement both interfaces in the same class because a single method can't return both String and int.

The Solution

Avoid designing interfaces with conflicting method signatures. If you control the interfaces, rename one method. If you don't, you may need an intermediate adapter class or design workaround.

Key Takeaway: When multiple interfaces declare methods with identical signatures and compatible return types, one implementation satisfies all contracts; incompatible return types create unresolvable conflicts that prevent compilation.