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
What are the object and class classes used for?
What is the file type?
Is stringwriter thread safe?
What is the purpose of a parameter?
What is split return?
What is collection sort in java?
What is the use of a copy constructor?
What's the access scope of protected access specifier?
How does enum work in java?
Is finalize() similar to a destructor?
Write a method that will remove given character from the string?
why Interface used?
How define set in java?
How can the checkbox class be used to create a radio button?
What is the applet security manager, and what does it provide?