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
Why destructor is not used in java?
What is string immutability?
What is getclass () getname () in java?
What do you understand by weak reference?
Explain the overview of UDP messaging.
What are java packages? What's the significance of packages?
What is the purpose of java?
What is lazy initialization in java?
What is the use of java?
Can we have any other return type than void for main method?
What does nextint () do in java?
How to display all the prime numbers between 1 and n (n is the number, get the input from user)
Is java code slower than native code?
Differentiate between stringbuffer and string?
What are invisible components?.