Why do we need main method to execute a java program?
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 |
Variables used in a switch statement can be used with which datatypes?
Can sleep() method causes another thread to sleep?
why an outer class cannot be declared as private?
What are identifiers in java?
What is void data type?
Is 'sizeof' a keyword?
What is the exact difference in between Unicast and Multicast object? Where will it be used?
What is double data type?
Does string is thread-safe in java?
What is JDK? Mention the variants of JDK?
What is the full name of java?
Can we override static methods?
18 Answers Bally Technologies,