What is the need to declare main() method as static in Java?

Answers were Sorted based on User's Feedback



What is the need to declare main() method as static in Java?..

Answer / juhi

If main method is static it should not be able to access any
other methods(other than static methods). but this is not
the case y?

Is This Answer Correct ?    1 Yes 0 No

What is the need to declare main() method as static in Java?..

Answer / 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

More Java Related AllOther Interview Questions

What is a driver in java?

0 Answers  


Is it better to learn java or python?

0 Answers  


What is the content of the Java 2 security policy file?

1 Answers  


What is dto layer in java?

0 Answers  


Why is lambda expression used?

0 Answers  






What is http session in java?

0 Answers  


What is a stream in programming?

0 Answers  


What about products that claim to block java applets at a firewall? : java security

0 Answers  


What is war file in java?

0 Answers  


What is java bean class?

0 Answers  


Which is the Best institute to do academic Project in Java? Need information about institutes at Ameerpet, Hyderabad.

8 Answers  


What does jpa mean?

0 Answers  


Categories