A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/java/jvm-create-object-main-class-class-contains-main/ below:

Does JVM create object of Main class (the class with main())?

Does JVM create object of Main class (the class with main())?

Last Updated : 23 Jul, 2025

Consider following program.

Java
class Main {
    public static void main(String args[])
    {
        System.out.println("Hello");
    }
}

Output:

Hello

Does JVM create an object of class Main? The answer is "No". We have studied that the reason for main() static in Java is to make sure that the main() can be called without any instance. To justify the same, we can see that the following program compiles and runs fine.

Java
// Note Main is abstract
abstract class Main {
    public static void main(String args[])
    {
        System.out.println("Hello");
    }
}

Output:

Hello

Since we can't create object of

abstract classes in Java

, it is guaranteed that object of class with main() is not created by JVM.


Does JVM create object of Main class?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4