Static method in Interface in Java Last Updated : 22 Sep, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Static Methods in Interface are those methods, which are defined in the interface with the keyword static. Unlike other methods in Interface, these static methods contain the complete definition of the function and since the definition is complete and the method is static, therefore these methods cannot be overridden or changed in the implementation class.Similar to Default Method in Interface, the static method in an interface can be defined in the interface, but cannot be overridden in Implementation Classes. To use a static method, Interface name should be instantiated with it, as it is a part of the Interface only.Below programs illustrate static methods in interfaces:Program 1: To demonstrate use of Static method in Interface.In this program, a simple static method is defined and declared in an interface which is being called in the main() method of the Implementation Class InterfaceDemo. Unlike the default method, the static method defines in Interface hello(), cannot be overridden in implementing the class. Java // Java program to demonstrate // static method in Interface. interface NewInterface { // static method static void hello() { System.out.println("Hello, New Static Method Here"); } // Public and abstract method of Interface void overrideMethod(String str); } // Implementation Class public class InterfaceDemo implements NewInterface { public static void main(String[] args) { InterfaceDemo interfaceDemo = new InterfaceDemo(); // Calling the static method of interface NewInterface.hello(); // Calling the abstract method of interface interfaceDemo.overrideMethod("Hello, Override Method here"); } // Implementing interface method @Override public void overrideMethod(String str) { System.out.println(str); } } Output: Hello, New Static Method Here Hello, Override Method here Program 2: To demonstrate Scope of Static method.In this program, the scope of the static method definition is within the interface only. If same name method is implemented in the implementation class then that method becomes a static member of that respective class. Java // Java program to demonstrate scope // of static method in Interface. interface PrintDemo { // Static Method static void hello() { System.out.println("Called from Interface PrintDemo"); } } public class InterfaceDemo implements PrintDemo { public static void main(String[] args) { // Call Interface method as Interface // name is preceding with method PrintDemo.hello(); // Call Class static method hello(); } // Class Static method is defined static void hello() { System.out.println("Called from Class"); } } Output: Called from Interface PrintDemo Called from Class Comment More infoAdvertise with us Next Article Static method in Interface in Java B bilal-hungund Follow Improve Article Tags : Java Static Keyword java-interfaces Practice Tags : Java Similar Reads Private Methods in Java 9 Interfaces Java 9 onwards, you can include private methods in interfaces. Before Java 9 it was not possible. Interfaces till Java 7 In Java SE 7 or earlier versions, an interface can have only two things i.e. Constant variables and Abstract methods. These interface methods MUST be implemented by classes which 4 min read Java Interface Methods In Java, an interface is an abstract type used to specify the behaviour of a class. One of the most important rules when working with interfaces is understanding how methods are declared and implemented. In this article, we are going to learn the interface methods in detail.Note: Interface methods a 3 min read Static Method vs Instance Method in Java In Java, methods are mainly divided into two parts based on how they are connected to a class, which are the static method and the Instance method. The main difference between static and instance methods is listed below:Static method: A static method is a part of the class and can be called without 4 min read Nested Interface in Java In Java, we can declare interfaces as members of a class or another interface. Such an interface is called a member interface or nested interface. Interfaces declared outside any class can have only public and default (package-private) access specifiers. In Java, nested interfaces (interfaces declar 5 min read Match Lambdas to Interfaces in Java One of the most popular and important topics is lambda expression in java but before going straight into our discussion, let us have insight into some important things. Starting off with the interfaces in java as interfaces are the reference types that are similar to classes but containing only abst 5 min read Like