Core Java: Static interface methods belong to the interface, not implementing classes

A static method on an interface is called only through the interface's own name; it is never inherited by implementing classes the way a default method is.

Code
interface MathOps {
    static int square(int x) { return x * x; }
    default int cube(int x) { return x * x * x; }
}
class Impl implements MathOps {}
System.out.println("Static via interface: " + MathOps.square(5));
System.out.println("Default via instance: " + new Impl().cube(3));
Output
Static via interface: 25
Default via instance: 27
Advertisement
More in JAVA

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-09-27

© Java Coding Hub · About · Contact · Privacy · Terms