Java Zero to All All questionsPractise free
Interview questions › Java Foundations — Zero to Basics › How Java Runs — JDK, JRE, JVM & Your First Program

Explain the signature `public static void main(String[] args)` piece by piece.

Level I · BeginnerHow Java Runs — JDK, JRE, JVM & Your First Program
Answer

It is the entry point the JVM calls to start your program. public means the JVM can call it from outside the class; static means it runs without first creating an object of the class; void means it returns nothing; main is the fixed name the JVM looks for; String[] args is the array of command-line arguments passed to the program. If this exact shape is missing, `java` fails with an error that it cannot find or launch main.

Common mistakes
  • Saying main must be public 'by convention' — the launcher requires it to be public and static.
  • Not knowing String[] args receives command-line arguments.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for How Java Runs — JDK, JRE, JVM & Your First Program.

Practise free

More on How Java Runs — JDK, JRE, JVM & Your First Program