Menu
Question Index
...

What will be the output of the following program?

class Fill3DArray
{
    public static void main(String args[])
    {
        int[][][] M;
        M = new int[2][2][3];
        for (int row = 0; row < 1; row++)
            for (int col = 0; col < 2; col++)
                for (int ver = 0; ver < 3; ver++)
                    M[row][col][ver] = row + col + ver;
        for (int row = 0; row < 1; row++)
            for (int col = 0; col < 2; col++)
                for (int ver = 0; ver < 3; ver++)
                    System.out.print(M[row][col][ver] + " ");
    }
}


0 1 2 1 2 3 1 2 3 2 3 4
0 1 2 1 2 3
0 1 1 2
0 1 2
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