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
How can I swap two variables without using a third variable?
Is jar an executable?
1.can i use super keyword in normal class(not inheritance) to call any method?if so how can i call particular variable? 2.In the inheritance how can i access the particular variable from the base class(it containing 5 variables) using super keyword?
What is microservices java?
What is rxjava2?
What is the locale class?
If you’re overriding the method equals() of an object, which other method you might also consider?
How does jpa repository work?
What are the rules regarding quotation marks?
What is mq in java?
What is a controller in java?
What is war file in java?
What is flatmap in rxjs?
Why is struts used in java?
How do I run a project in eclipse?