What is the need to declare main() method as static in Java?
Answer Posted / bsridhar1984
main() is the entry point of the java program for JVM. If it
is not static and have to call main method, JVM has to
create the object for that class. At this situation
constructor of that class will be entry point.
So that main() method of that class should be static. Then
only JVM can access the main method directly without
creating object of the program.
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
What is the difference between ec2 and lambda?
Is jvm a compiler or an interpreter?
What are the advantages of lambda functions?
What is lambda used for?
What java systems libraries and methods are available for me to use?
Can the main method be overloaded?
What is interceptors in java?
What is contextpath in java?
If you’re overriding the method equals() of an object, which other method you might also consider?
Is java installed on windows 10?
How can I write a program that takes command line input?
What is transactional in java?
What is the use of flatmap?
What is mq in java?
What is jpa entitymanager?