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


Please Help Members By Posting Answers For Below Questions

Explain about exception propagation?

583


What is use of arraylist in java?

579


Mention a package that is used for linked list class in java.

522


Can a class be final?

494


What is the functionability stubs and skeletons?

680






Whats the difference between notify() and notifyall()?

564


What is the simpletimezone class in java programming?

533


I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com

1069


What does a void function return?

543


Can long be null in java?

540


Why java is call by value?

542


How to perform binary search in java?

567


What is bool mean?

563


What is the right data type to represent a price in java?

563


Is array primitive data type in java?

529