Static method in Interface in Java Last Updated : 22 Sep, 2021 Comments Improve Suggest changes 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 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 Evolution of Interface in Java In Java, interfaces define a contract for classes without specifying how the methods are implemented. With time, Java has introduced major enhancements or we can say evolution of interfaces to make them more powerful. So, in this article, we will explore the evolution of interfaces in Java from Java 3 min read Class isInterface() method in Java with Examples The isInterface() method of java.lang.Class class is used to check if this Class is an interface. The method returns true if this Class is an interface. It returns false otherwise. Syntax: public boolean isInterface() Parameter: This method does not accept any parameter. Return Value: This method re 2 min read Interfaces and Polymorphism in Java Java language is one of the most popular languages among all programming languages. There are several advantages of using the java programming language, whether for security purposes or building large distribution projects. One of the advantages of using JA is that Java tries to connect every concep 5 min read Serializable Interface in Java The Serializable interface is present in java.io package. It is a marker interface. A Marker Interface does not have any methods and fields. Thus classes implementing it do not have to implement any methods. Classes implement it if they want their instances to be Serialized or Deserialized. Serializ 2 min read Like