Java Programming - Language Fundamentals - Discussion

Discussion Forum : Language Fundamentals - Finding the output (Q.No. 1)
1.
What will be the output of the program?
public class CommandArgsThree 
{
    public static void main(String [] args) 
    {
        String [][] argCopy = new String[2][2];
        int x;
        argCopy[0] = args;
        x = argCopy[0].length;
        for (int y = 0; y < x; y++) 
        {
            System.out.print(" " + argCopy[0][y]);
        }
    }
}

and the command-line invocation is

> java CommandArgsThree 1 2 3

0 0
1 2
0 0 0
1 2 3
Answer: Option
Explanation:
In argCopy[0] = args;, the reference variable argCopy[0], which was referring to an array with two elements, is reassigned to an array (args) with three elements.
Discussion:
36 comments Page 4 of 4.

Dima said:   1 decade ago
Where is the first space character?

Abhijit said:   1 decade ago
Can anyone explain how is it come?

John said:   2 years ago
Please explain the answer clearly.
(1)

Eric said:   1 decade ago
How do I invoke the command line?

Ravindra said:   1 decade ago
How it is possible ?

Disha said:   1 decade ago
Please explain me.


Post your comments here:

Your comments will be displayed after verification.