InterviewSolution
Saved Bookmarks
| 1. |
Why is the main method static in Java? |
|
Answer» The main method is always STATIC because static MEMBERS are those methods that belong to the classes, not to an individual object. So if the main method will not be static then for every object, It is available. And that is not acceptable by JVM. JVM calls the main method based on the class name itself. Not by creating the object. Because there MUST be only 1 main method in the java program as the execution starts from the main method. So for this reason the main method is static. |
|