Multiple choice technology programming languages

A class without main method can be compiled successfuly.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A Java class can be compiled successfully without a main method. The main method is only required if you want to run the class as an application. Classes without main methods can be compiled and used as libraries, or they can be extended/instantiated by other classes that do have main methods. The Java compiler (javac) compiles any valid Java syntax regardless of whether a main method is present. The main method is an entry point for execution, not for compilation.