top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Does Java Virtual Machine create object of Main class (the class in which main() is present) ?

+1 vote
56 views
Does Java Virtual Machine create object of Main class (the class in which main() is present) ?
posted Aug 5, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

No, JVM doesn't create object of the main class.In java main() is static to make sure it will be called without any instance. So it means there is no need of object to execute main() method.

Check below program:-

abstract class MainClass {
    public static void main(String args[])
    {
        System.out.println("Inside Main Method");
    }
}

Output: Inside Main Method

Since we cannot create object of abstract classes in Java, it is guaranteed that object of class with main() is not created by Java Virtual Machine.

answer Aug 5, 2016 by Salil Agrawal
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...