What happens if we don't declare the main method as static?

If the main() method is not declared as static, the JVM cannot invoke it to start the application. This is because the JVM calls the main() method before creating any object of the class, and a non-static method requires an object instance to be invoked.

Key Points

Example

If the main() method is declared without the static keyword, the JVM cannot start the program because it has no object available to invoke the method.

public class Test {

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

Runtime Error

Error: Main method is not static in class Test,

please define the main method as

public static void main(String[] args)

Interview Tip

A concise interview answer is

If the main() method is not static, the JVM cannot invoke it because no object exists when the application starts. Therefore, the program will not run, and the JVM will report that the main method must be declared as static.

Last updated: 11 November 2026

Previous question: Why are object-oriented languages used in enterprise projects?

Next question: Can we override the main method?

More Core Java - Level II interview questions

All Core Java - Level II questions