Multiple choice technology programming languages

The main method has to be "public static" because of the following reasons. (Two options)

  1. static because it has to be constant and cannot be changed.

  2. static because it has to be loaded by the JVM without instantiating it

  3. public because other classes may also call the main method of a class

  4. public because JVM has to have access to the main method in order to call it.

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

The main method must be static so the JVM can invoke it without creating an instance of the class (no object exists at program startup). It must be public so the JVM, which is external to your class, can access it. Static methods belong to the class itself, not instances, and public allows unrestricted access from outside.