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


Please Help Members By Posting Answers For Below Questions

What is predicate in lambda expression?

638


Why do we need framework in java?

635


Are there tuples in java?

717


What is difference between loosely coupled and tightly coupled in java?

621


What is @resource annotation in java?

696


What is the meaning of loosely coupled in java?

680


What is jpa entitymanager?

665


What is a stream in java?

717


How common are security breaches? : java security

699


Can optional be null?

731


What is difference between map and flatmap in java 8?

665


What is java bean class?

699


What is tight coupling in java?

702


What are the Advantages of java se 8 new features?

736


What is a pojo class in java?

714