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


Please Help Members By Posting Answers For Below Questions

What is transient in java?

559


How do I export a java project?

550


What is transactional in java?

610


Why is javac not recognized?

562


Can the main method be overloaded?

634






What is jpa used for?

580


In java what is the difference between sleep() and wait() .

579


What is the use of flatmap in java 8?

540


Can we use lambda without functional interface?

588


What is tuple2?

575


What is property file in java?

552


What is java api?

523


What is the meaning of loosely coupled in java?

534


Does netbeans need jdk?

559


What is java ioc?

566