What output is produced for the command: "java cmd a b c d", when following…
2024
What output is produced for the command: "java cmd a b c d", when following code is run? class cmd { public static void main(String args[]) { System.out.println(args[2]); } }
- A.
c
- B.
cmd
- C.
b
- D.
a
- E.
Question not attempted
Attempted by 104 students.
Show answer & explanation
Correct answer: A
When running "java cmd a b c d", arguments are stored in the String array args. Index 0 is 'a', index 1 is 'b', and index 2 is 'c'. The code prints args[2], resulting in output: c.