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

How do you represent a space in regex java?

534


What is nextline method in java?

570


What is the difference between method overriding and overloading?

591


Explain serialization and deserialization in java?

569


Explain different types of wrapper classes in java?

609






Can we override private method in java?

629


What is module in oop?

576


What is json parser in java?

626


Why we use set in java?

529


Why is singleton class used?

537


What is Session reduplication and how its done?

1576


What is join () in java?

536


Is arraylist zero based?

564


Why is boolean important?

603


What is formatted output in java?

507