Skip to content
UniCircle
EasyConceptualJava platform basics

Explain public static void main(String[] args)

Question JAVA-BAS-003

Explain each part of public static void main(String[] args). What happens if you leave out static?

Show the explanation

Each keyword has a job:

  • public — the launcher, which is outside your class, must be able to call it.
  • static — the JVM calls it without creating an object of the class first.
  • void — it returns nothing; to report a status, call System.exit(code).
  • main — the name the launcher looks for.
  • String[] args — the command-line arguments (String... args also works).
Java
public class Greet {
    public static void main(String[] args) {
        String who = args.length > 0 ? args[0] : "world";
        System.out.println("Hello, " + who);
    }
}
// java Greet Asha  ->  Hello, Asha

Without static, the class still compiles. On Java 8–24 the launcher then refuses to run it ("Main method is not static…"). Java 25 made instance main methods a standard feature, so there the launcher creates an object and calls the non-static main. Interviewers usually expect the classic answer, so give it first and mention the Java 25 change as a bonus.

Original UniCircle question. Last reviewed 22 Oct 2026.