OCA Java SE 8 Mock Exam Review - OCA Mock Question 8


Given the following definition of the class Main,

 class Main { 
    public static void main(String[] args) { 
        System.out.println(args[1]+":"+ args[2]+":"+ args[3]); 

what is the output of the previous class, if it is executed using the command:

java Main one two three four 
  1. one:two:three
  2. Main:one:two
  3. java:Main:one
  4. two:three:four




The command-line arguments passed to the main method of a class do not contain the word Java and the name of the class.

The position of an array is zero-based, the method argument is assigned the following values:

args[0] -> one 
args[1] -> two 
args[2] -> three 
args[3] -> four