What is the need to declare main() method as static in Java?
Answer Posted / bsridhar1984
main() is the entry point of the java program for JVM. If it
is not static and have to call main method, JVM has to
create the object for that class. At this situation
constructor of that class will be entry point.
So that main() method of that class should be static. Then
only JVM can access the main method directly without
creating object of the program.
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
What is adoptopenjdk?
Can we use lambda without functional interface?
Why is javac not recognized?
What is jpa implementation?
Do I need to install jre if I have jdk?
What is numberformatexception in java?
What is persistence xml in java?
What is a service layer in java?
What is @resource annotation in java?
What is the difference between a jdk and a jvm?
How do I run a project in netbeans?
What is web xml java?
When do we go for java 8 stream api? Why do we need to use java 8 stream api in our projects?
How do I run a java project?
What is maven in java?