Menu
Topics Index
...
`

Command Line


If you need explanation Read this topic

If you need Answer Take test on this topic

Command Line
What will be the output of the following program? Assume that the argument passed as - "Is the program Execute or Not".
public class CommandLine {
    public static void main(String args[]) {
        for (int i = 0; i < args.length; i++)
            System.out.println("args[" + i + "]: " + args[i]);
    }
}

A. args[0]: Is
args[1]: the
args[2]: program
B. args[0]: Is the program Execute or Not
C. args[0]: Is
args[1]: the
args[2]: program
args[3]: Execute
args[4]: or
args[5]: Not
D. Some other output
E. Compilation Error or Runtime Error
Topic: for Loop In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is C...when a space is encountered it takes as one argument...so we have 6 args here..

Posted by Santosh Munugota    2013-10-28 09:14:38


ans is B...as the whole sentence is passed as an argument in double quotes...it considers it as the single argument.

Posted by Sneha Rapool    2013-10-28 09:27:06


c

Posted by Veerendhar Reddy    2013-10-28 10:07:02


"veerendhar and sandeep ans b yar" be careful while answering

Posted by Basanth Yarraguntla    2013-10-28 10:26:37


C is the answer because .every string which is given as input through cmnd line starts getting stored from index 0 of array.string getting seperated with space is treated as a single string.

Posted by Asad Ahmed    2013-10-28 16:45:33


Congratulations Sneha Rapool. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2013-10-29 03:54:32


© meritcampus 2019

All Rights Reserved.

Open In App