Home » JAVA Programming » Arrays » Question
  1. What is the output of this program?

    public class Result
    {
    public static void main(String[] args)
    {
    int []p[] = {{1,2}, {3,4,5}, {6,7,8,9}};
    int [][]q = p;
    System.out.println("Alligator");
    System.out.println(q[0][0]);
    }
    }

    1. Alligator
      1
    2. Alligator
      2
    3. Alligator
      3
    4. Alligator
      4
    5. Alligator
      5
Correct Option: A

Both p,and q are pointing to the same array.



Your comments will be displayed only after manual approval.