Multiple choice technology programming languages

What does the zeroth element of the string array passed to the public static void main method contain?

  1. The name of the program

  2. The number of arguments

  3. The first argument if one is present

  4. All the arguments

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

In Java's main(String[] args), args[0] is the first command-line argument passed to the program. Unlike C/C++, Java does not include the program name in the args array. If no arguments are provided, the array is empty and accessing args[0] would throw ArrayIndexOutOfBoundsException.