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
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 3 of 4.
Jyothi said:
1 decade ago
Can anyone explain this clearly because I don't know java.
I'm trying to analyse using C. Help me out.
I'm trying to analyse using C. Help me out.
Cat said:
1 decade ago
As I don't know anything about java so please explain me clearly. Don't hesitate to help me.
Sonal Bhutada said:
1 decade ago
I m not able to understand. Please explain it in a much easier way.
Surbhi said:
5 years ago
Thank you so much for explaining. It's very useful.
(2)
Anita said:
1 decade ago
Here argcopy declared within 2 dimensional array.
P .naresh said:
1 decade ago
What is the basic programming structure of java?
Sharma said:
8 years ago
I can't understand. How output will 1, 2, 3?
Nikhil said:
10 years ago
Please anyone explain code line by line.
USHA said:
10 years ago
Please explain me with simple example.
Eric said:
1 decade ago
How do I get this program to execute?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers