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
Is eclipse a jdk?
Which is better openjdk or oracle jdk?
What are the new features about Java se 8 ?
What is entitymanager in jpa?
What is data persistence in java?
What is lambda value?
What is the use of flatmap in java 8?
Does ms edge support java?
How can I swap two variables without using a third variable?
What is a controller in java?
What is the difference between collection and stream?
What are orm tools in java?
In a barber shop there are 2 doors. customer come in 1 door, leave in other. minimum # of chairs. barber spend his life in cutting. always barber can cut 1 customer. few chairs in the shop. if barber busy customer waits, if chairs full, customer leave. if no customer, barber sleeps. treat barber and customer as 2 threads. you can use Semaphore class with arrive and depart and count as parameter.
If you’re overriding the method equals() of an object, which other method you might also consider?
What is the meaning of loosely coupled in java?