What is the need to declare main() method as static in Java?
Answer Posted / dadhich
main method is declared as static because we cannot call the method without creating the object of the class.When we declare class and in which if we define main method then it is must to use the static keyword.static keyword helps to execute the main method without instantiating the class.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What is custom tag in java?
Does jvm maintain a cache by itself? Does the jvm allocate objects in heap? Is this the os heap or the heap maintained by the jvm? Why
What is jep in java?
What is contextpath in java?
What is meant by code profiling?
What's a code group? : java security
Why dependency injection is used in java?
What is the difference between map and flatmap in java?
What are jpa repositories?
Why do we need framework in java?
What is the difference between ec2 and lambda?
How long can a lambda function run?
Is jvm a compiler or an interpreter?
What is profile in java?
What is difference between map and flatmap in java 8?