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 the restrictions imposed on method overriding?

0 Answers  


What are internal variables?

0 Answers  


How do you create a reference in java?

0 Answers  


How does remove work in java?

0 Answers  


What is an anonymous class?

1 Answers   IBM,






What is parameters example?

0 Answers  


please send me hr interview questions in it industry

0 Answers  


When you declare a method as abstract method ?

2 Answers   HP,


Can java cast null?

0 Answers  


Can we make main() thread as daemon?

0 Answers  


Explain about complier design(phases)

0 Answers   Aditi Placement Service,


How a class can implement an interface?

5 Answers   SysArc,


Categories