What is the output of this program?

class CommandLineArg2
{
static public void main(String[] args)
{
String[] alt={"X","Y","Z"};
args=alt;
for(int i=0;i<args.length;i++)
{
System.out.println(args[i]);
}
}
}
/*
Output:- X
Y
             Z
Explanation:- Reference address of args is replced by this statement "args=alt". Hence now args
will point to "X Y Z".
*/

0 comments: