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
Which class cannot be a subclass in java?
How to change the priority of thread or how to set the priority of thread?
What is the difference between yielding and sleeping?
What is increment in java?
Why can't you declare a class as protected?
Write a program in java to create a doubly linked list containing n nodes.
What interface is extended by awt event listeners?
What is a ternary operator in java?
What is the use of conditional statement?
Difference between Linked list and Queue?
When is the finalize() called? What is the purpose of finalization?
what are different ways in which a thread can enter the waiting state? : Java thread
Is arraylist ordered?
Can a final method be overloaded?
What is the use of predicate in java 8?