adplus-dvertising
frame-decoration

Question

What is the output of this program?
    class multidimention_array 
    {
        public static void main(String args[])
        {
            int arr[][] = new int[3][];
            arr[0] = new int[1];
            arr[1] = new int[2];
            arr[2] = new int[3];               
     int sum = 0;
     for (int i = 0; i < 3; ++i) 
         for (int j = 0; j < i + 1; ++j)
                    arr[i][j] = j + 1;
     for (int i = 0; i < 3; ++i) 
         for (int j = 0; j < i + 1; ++j)
                    sum + = arr[i][j];
     System.out.print(sum);  
        } 
    }

a.

11

b.

10

c.

13

d.

14

Posted under Java Programming

Answer: (b).10

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?