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 an api in java?

0 Answers  


please suggest me final year project ideas for computer engg.on java as soon as possible becaus eo want to sumbit project name. and i am very confused.

1 Answers  


What is aop java?

0 Answers  


Can an application have multiple classes having main method?

0 Answers  


Which is more secure: java or activex? : java security

0 Answers  


How to implement Thread

2 Answers  


How can I swap two variables without using a third variable?

0 Answers  


What are tlds in java?

0 Answers  


What is explicit casting?

0 Answers  


What is a flatmap?

0 Answers  


What is the difference between Enumeration and Iteration interfaces? What is the way of to retreive the objects from these interfaces ?

1 Answers   Cap Gemini,


What is exe file in java?

0 Answers  


Categories