Home / Java Programming / Language Fundamentals :: Discussion

Discussion :: Language Fundamentals

  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 xz         
             argCopy[0] = args;     
             x = argCopy[0].length;  
             for (int y = 0; y
             }
                 System.out.print(" " + argCopy[0][y]);     
             }    
          } 
      }     

    and the command-line invocation is

    > java CommandArgsThree 1 2

  2. A.

    0 0

    B.

    1 2

    C.

    0 0 0

    D.

    1 2 3

    View Answer

    Workspace

    Answer : Option D

    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.


Be The First To Comment