Javatpoint Logo

Q) In java main method is static Why ?

By: devida*** On: Tue Aug 01 22:34:06 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
Please give answerUp0Down

 
when we are running java file it goes to JVM. JVM knows the name of class but creating object of that class and then call main method is overhead for JVM that reason we make that main method static. advantage of doing that is we can able to call static main method by class name without creating object.that reason we are making main method as static. Image Created0Down

By: [email protected] On: Thu Aug 03 12:33:22 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
so JVM needs not to make object of main classImage Created0Down

By: [email protected] On: Wed Aug 09 11:35:30 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
Main method needs to be accessed from outside the class without creating any objectof the class.That's why main method should be static.Image Created0Down

By: [email protected] On: Mon Sep 11 10:49:06 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No