What is the need to declare main() method as static in Java?
Answer Posted / dadhich
main method is declared as static because we cannot call the method without creating the object of the class.When we declare class and in which if we define main method then it is must to use the static keyword.static keyword helps to execute the main method without instantiating the class.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
Can an application have multiple classes having main method?
How do I create an executable jar file?
What if the main method is declared as private?
What is optional in java 8? What is the use of optional?advantages of java 8 optional?
How do I open the java control panel?
What is flatmap java?
What is predicate in lambda expression?
What if I do not provide the string array as the argument to the method?
In hibernate what is the difference between the Session and SessionFactory?
Why struts framework is used in java?
How does java handle integer overflows and underflows?
Explain the common use of ejb?
How many types of jdk are there?
What do you understand by numeric promotion?
Is jar an executable?