Originally posted by Bhaswati Karmakar:
What all gets printed on the standard output when the class below is compiled and executed by entering "java test lets see what happens". Select all correct answers.
public class test {
public static void main(String args[]) {
System.out.println(args[0]+" "+args.length);
}
}
A.java
B.test
C.lets
D.3
E.4
F.5
G.6
Why are answers C & E correct ? I think it's A & G. Please explain.
In Java, the argument list starts after the class name.
So here "test" is the class name, after which we have the argument
list. There are total four arguments, so args.length = 4
And arg[0] = lets
args[1] =see
args[2] =what
args[3] =happens