Question 1
Given the following program:
public class Test {
public static void main(String[] args) {
| for (int i = 0; i < args.length; i++) { |
| System.out.print(args[i] + " "); |
}
}
What is the output, if you run the program using the following?
java Test 1 2 3
◦ 1 2
◦ 1
◦ 1 2 3
◦ 3
Question 2
Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?
◦ int count=0; while (!(args[count].equals(""))) count ++;
◦ int count = args.length - 1;
◦ int count = args.length;
◦ int count = 0; while (args[count] != null) count ++;