Java OCA OCP Practice Question 1899

Question

Consider the following program:

public class Main{
  public static void main (String [] args){
    String a = args[0];
    String b = args[1];
    String c = args[2];
   }
 }

What will the value of 'c' if the program is run from the command line:

java Main  111 222 333

Select 1 option

  • A. 111
  • B. 222
  • C. 333
  • D. It will throw an ArrayIndexOutOfBoundsException
  • E. None of the above.


Correct Option is  : C

Note

java and classname are not part of the args array.

So a gets "111", b gets "222" and c gets "333".




PreviousNext

Related