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

Static Methods Across Multiple Interfaces

Understand that static methods in interfaces don't conflict because they're called via interface name, not instances.

What You'll Learn

You'll learn why static methods in multiple interfaces never conflict—even if they have identical names—and how to call them explicitly using the interface name.

The Core Idea

Unlike instance methods and default methods, static methods in interfaces belong to the interface itself, not to implementing classes or instances. This means when you implement multiple interfaces that each have static methods with the same signature, there's no conflict at all. The methods don't compete because they're accessed differently: you call them using the interface name, like InterfaceName.methodName(), never through an object or implementing class.

Think of it like this: if two libraries each publish a dictionary, both titled "Dictionary," there's no confusion as long as you specify which library's dictionary you're reading. Static interface methods work the same way—you always say which interface you're calling from.

How Static Methods Differ from Default Methods

When implementing multiple interfaces:

  • Default methods can conflict (same signature → compiler error unless resolved)
  • Static methods cannot conflict (they're not inherited; each stays in its own interface)

An implementing class doesn't "inherit" static methods from its interfaces. The class can't override them, can't access them via super, and can't call them without explicitly naming the interface.

Calling Static Methods from Multiple Interfaces

To call a static method, you must use the interface name as a qualifier:

InterfaceA.staticMethod();
InterfaceB.staticMethod();

Even if a class implements both InterfaceA and InterfaceB, and both have staticMethod(), you choose which one to invoke by naming the interface directly.

Key Takeaway:
Static methods in interfaces are namespaced by the interface itself, so multiple interfaces can safely have identically-named static methods without any conflict—you simply specify which interface you're calling.