Why do we need main method to execute a java program?
Answer Posted / 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 View All Answers
How do you clear an arraylist in java?
What is boolean used for?
Can we override data members in java?
What are the different ways of implementing thread? Which one is more advantageous?
What about static nested classes in java?
Can a final variable be null?
How do you reverse a string in java without using string buffer?
What is the difference between @before and @beforeclass annotation?
What are java threads?
How large is a boolean?
Can we declare register variable as global?
What is core java used for?
How many types of literals are there in JAVA?
What is numel matlab?
Explain restrictions for using anonymous inner classes?