Multiple choice technology programming languages

What will be printed out if this code is run with the following command line? java myprog good morning public class myprog{ public static void main(String argv[]) { System.out.println(argv[2]); } }

  1. myprog

  2. good

  3. morning

  4. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"

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

When Java is invoked with 'java myprog good morning', the command-line arguments array argv[] contains only [good, morning], with indices 0 and 1. Accessing argv[2] attempts to read beyond the array bounds, causing an ArrayIndexOutOfBoundsException. The program name 'myprog' is not in the argv array.