Java
Programming and Technical
Programming
Program
Why main method is static?
Read Solution (Total 4)
-
- main method is static because it is the main method that gets executed first before any other methods. Since main is static at the time of class loading , memory gets allocated for the static members , main being the first of them. Because static members are strictly associated with class and in no way deals with object creation
- 9 years agoHelpfull: Yes(1) No(0)
- because without creating object, it can be accessed using class name directly .
- 9 years agoHelpfull: Yes(0) No(0)
- the main() method is static because if it is not static then the jvm will create object first thus it will add overhead and consume large memory.
- 6 years agoHelpfull: Yes(0) No(0)
- Static elements get loads with the class itself in the memory, so there is no need to create the instance for the main method. It will get loaded while the class loading in the memory, thus avoiding the creation of unnecessary instances.
- 3 years agoHelpfull: Yes(0) No(0)
Java Other Question