Why is the main() method declared static?

1 votes
408 views
Anonymous User asked 21-Dec-2017 in Technology by Anonymous User

Why is the main() method declared static?

1 Answer

0 votes
Harsh kumar srivastava answered 21-Dec-2017 by Harsh kumar srivastava

The main() method is declared static because it's called by JVM before instantiation of the class. And it's also necessary because it's called by JVM before any objects are made. Due to this, we declare main() method static because they can then be invoked by the runtime engine without having to instantiate an instance of the parent class.

Hope it's informative for you...