JavaIntermediate#interface#java8

What is the difference between an interface's default method and a static method?

A default method provides a concrete implementation that implementing classes inherit and can override; it's called on instances. A static method belongs to the interface itself, cannot be overridden by implementing classes, and is called via the interface name.

Example
interface Vehicle {
  default void honk() { System.out.println("Beep"); } // inherited, overridable
  static Vehicle createDefault() { return new Car(); } // called as Vehicle.createDefault()
}

Related Questions

1
JavaAdvanced#streams#exceptions

What is the difference between checked exception wrapping in streams' lambdas — why can't you throw checked exceptions inside a lambda directly used in a stream?

Open
2
JavaAdvanced#collections#oop

What is the difference between the Comparable interface's compareTo() contract and a poorly implemented one?

Open
3
JavaBeginner#jvm#fundamentals

What is JVM?

Open