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

What are constants and how to create constants in java?

0 Answers  


What are the types of inner classes (non-static nested class) used in java?

0 Answers  


I want to run a simple hello world java (HelloWorld.java) program using a batch file. How can i run it and how to construct a batch file.

1 Answers   Infosys,


What is mvc in java?

0 Answers  


Differences between traditional programming language and object oriented programming language?

0 Answers  






What is difference between overloading and overriding in java?

0 Answers  


How to create com object in Java?

0 Answers  


What is stored procedure. How do you create stored procedure ?

0 Answers   GE,


When is the garbage collection used in Java?

0 Answers   BirlaSoft,


hi to all. well can you please tell me that why String class is immutable? Thanks in advance.

5 Answers   Huawei,


How do you do a line break in java?

0 Answers  


What is the use of runnable interface?

0 Answers  


Categories