Why do we need main method to execute a java program?



Why do we need main method to execute a java program?..

Answer / javamasque

Main method is auto called by JVM. It is the place, where JVM enters into the class. It is called before the class is instantiated by its constructor. There are below reasons on its signature.
1. Public access modifier: it is visible to outer environment called JVM.
2. Static non-access modifier: it is called before the class is instantiated, hence JVM use class name to call the main method.
3. Void return type: It return no value to JVM.
4. String array parameter: It takes command line arguments.

Is This Answer Correct ?    11 Yes 1 No

Post New Answer

More Core Java Interview Questions

Explain jvm, jre, and jdk?

0 Answers  


What is covariant return type?

0 Answers  


What do you understand by access specifiers in Java?

0 Answers   Genpact,


Write a program to print fibonacci series

0 Answers  


What type of variable is error flag?

0 Answers  






Is alive and join method in java?

0 Answers  


What is sizeof () operator?

0 Answers  


What methodology can be employed to locate substrings inside a string?

0 Answers  


What is package protected in java?

0 Answers  


what is the need to set path in java? how many ways to set path in java? Explain breif?

5 Answers  


different types of threads?

18 Answers   TCS,


What is string value?

0 Answers  


Categories