What is the result of the following when run with java mypkg.Main September 3 2020?
package mypkg; public class Main { public static void main(String[] args) { for (int i = args.length; i>=0; i--) System.out.println(args[i]); } }
D.
There are three arguments passed to the program.
This means that i is 3 on the first iteration of the loop.
The program attempts to print args[3].
Since indexes are zero based in Java, it throws an ArrayIndexOutOfBoundsException.