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


Please Help Members By Posting Answers For Below Questions

What is collection sort in java?

559


What are the important features of Java 8 release?

582


What is parsing a sentence?

550


What are thread safe functions?

516


What is singleton class and how can we make a class singleton?

661






How do generics work?

522


Where is the singleton class used?

587


What is java util?

541


What is callablestatement? How you can call stored procedure to pass in parameter?

545


Tell me the Importent classes in net package?

1584


What is the public method modifier?

548


Can we create our own daemon thread?

544


Do you know how to reverse string in java?

588


What do you mean by pointer value and address?

581


Explain the features of interfaces in java?

558