Menu
Question Index
...

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);
            }
        }
    }
}


7
9
11
13
Compilation Error or Runtime Error

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App