Menu
Topics Index
...
`

Multi Dimensional Arrays and Loops


If you need explanation Read this topic

If you need Answer Take test on this topic

Multi Dimensional Arrays and Loops
How many lines of output will the following program produce?
public class Test {

    public static void main(String[] args) {
        int[][][] num = new int[3][][];
        int i, j;
        num[0] = new int[4][];
        num[1] = new int[2][];
        num[2] = new int[5][];
        for (i = 0; i < num.length; i++) {
            for (j = 0; j < num[i].length; j++) {
                num[i][j] = new int[i + j + 1];
                System.out.println("size = " + num[i][j].length);
            }
        }
    }
}

A. 7
B. 9
C. 11
D. 13
E. Compilation Error or Runtime Error
Topic: Learn Arrays And Loops

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

answer is c .because for i=0 it  produces 4 lines of output ,for i=1 it produces 2 lines,i=2 it produces 5lines so toral 11

Posted by Aparna Kanjarla    2014-03-06 04:45:35


Congratulations Aparna Kanjarla. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-03-07 04:58:45


© meritcampus 2019

All Rights Reserved.

Open In App