Interface main method
Every java class starts from main() method. And if we mention main() method in interface and run it directly then main() executes, how? Please someone explain.
First thing you must understand is by default every class or interface you create are saved with .java extension. So the JVM is only looking for a main() which is public, static and void. It doesn't matter if it is inside a public class or interface. So until Java version 7 this was not possible because you cannot declare static methods inside an interface. But Java 8 introduced static and default methods in interface which made this possible. This code will show the version used and a statement inside the interface. https://code.sololearn.com/cj3e8s6NIm6W/?ref=app
yup got it now. since jdk 8, its possible, checked on older version too. interface treat main() method as regular static method but JVM search for main(). class and interface are equal for JVM. Thank you.