Can we Execute a program without main() method in JAVA? Answer is Here.

This is the most frequently asked question in JAVA. So, here is a simple answer for this.


Ans:

No, one of the ways was the static block, but unfortunately, it was possible till JDK version 1.6. 

Since, from JDK version 1.7 it's not possible to execute a JAVA program without main() method. So,  it is necessary to declare main() method to compile or run a JAVA program.

💡 You can declare main() method as: public static void main(String args[])


Previous Post Next Post

Contact Form