What is the need to declare main() method as static in Java?
Answer Posted / kuldeep vishwakarma
We know very well that when we want to call any method without creating Class object in which that method is reside,this will
be perform by "static" keyword.And in java main()always call by JVM,So we can call main()without instance create with the help of jvm.Therefore we needed static with main();
INTERNALLY MAIN()CALL WITH THE HELP OF TRY-CATCH BLOCK
try{
ClassName.main();
}
catch(Exception e)
{
---------------
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is java lang exceptionininitializererror?
What is dto in java?
What is the use of flatmap in java 8?
Is java built on c?
How do I enable java in firefox?
What is the use of entity class 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.
What is the difference between Logical Parallelism and Physical Parallelism?
Why is class forname used in java?
Why is struts used in java?
If you’re overriding the method equals() of an object, which other method you might also consider?
Explain the inheritance principle.
What are the disadvantages of java sockets?
Are the actual permissions for the application defined at run-time or compile-time? : java security
Where is java installed?