Suppose that we have the following two dimensional array Wha

Suppose that we have the following two dimensional array. What is the output of each of the followings?

int[][] num = { { 3, 2, -1, 3}, {-2, 4, 7, -3}, {9, 4, -1, 0},{2, 8, -3, 7 }};

System.out.println(num.length);

System.out.println(num[2].length);

System.out.println(num[3][0]);

System.out.println(num[2][3]);

System.out.println(num[0][3]);

system.out.println(num[2][2]);

System.out.println(num[0][0]);

Solution

Answer:

System.out.println(num.length); will print 4

This statement will print number of rows in array.
       System.out.println(num[2].length); will print 4

This statement will print number of columns in array.
       System.out.println(num[3][0]); will print 2

This statement will print 4th row and 1st column value.
       System.out.println(num[2][3]); will print 0

This statement will print 3th row and 4th column value.
       System.out.println(num[0][3]); will print 3

This statement will print 1th row and 4th column value.
       System.out.println(num[2][2]); will print -1

This statement will print 3rd row and 3rd column value.
       System.out.println(num[0][0]); will print 3

This statement will print 1st row and 1st column value.

Suppose that we have the following two dimensional array. What is the output of each of the followings? int[][] num = { { 3, 2, -1, 3}, {-2, 4, 7, -3}, {9, 4, -

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site