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

If you’re overriding the method equals() of an object, which other method you might also consider?

0 Answers  


What is the point of lambda expressions?

0 Answers  


How do I run a java project in netbeans?

0 Answers  


Is it better to learn java or python?

0 Answers  


Can I have multiple main methods in the same class?

0 Answers  






How do I open the java console in windows 10?

0 Answers  


What is meant by pass by reference and pass by value in java?

0 Answers  


What is profile in java?

0 Answers  


Why is lambda expression used?

0 Answers  


Who developed rxjava?

0 Answers  


If one class havent the constructor, it has normal method, then can i use super keyword to call the method form the sub class and vice verse?

2 Answers  


there are 67 seats in train . there are only 5 seats in a row and in last row there are only 2 seats. One person can reseve only 5 seat at a time. If person reserving seat , the care is atken that he may get all in row. if seats are not available in row then the arrangement is so that person group get nearby seats. the following class is given public class seat { char name; int seat; boolean isSeatempty } 1.Draw require class digram and object diagram. 2.Write function seatallot(int noofperson) to allocate seat with seat nuber printed for the each name.

0 Answers   Sapient,


Categories