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 a jvm?

723


Is java singleton thread safe?

649


What do you understand by numeric promotion?

718


Why is javac not recognized?

645


What is aop java?

627


What is the use of flatmap in java 8?

632


Does ms edge support java?

625


What is jar file in java?

714


What is mime in java?

681


What is lambda expressions action func and predicate?

618


Name primitive java types.

697


What is transactional in java?

723


How do I install jdk?

651


What is scrollable resultset in java?

666


Write a program using call by refernce for two different classes to explain to print whether a given number is automorphic or not.

1600