Question: Can the rows in a two - dimensional array have different lengths? 2 ) What is the output of the following code? int [ ]

Can the rows in a two-dimensional array have different lengths?
2) What is the output of the following code?
int[][] array = new int[5][6];
int[] x ={1,2};
array[0]= x;
System.out.println("array[0][1] is "+ array[0][1]);
3) Show the output of the following code:
int[][] array ={{1,2},{3,4},{5,6}};
for (int i = array.length -1; i >=0; i--){
for (int j = array[i].length -1; j >=0; j--)
System.out.print(array[i][j]+"");
System.out.println();
}
4) Show the output of the following code:
public class Test {
public static void main(String[] args){
int[][] array ={{1,2,3,4},{5,6,7,8}};
System.out.println(m1(array)[0]);
System.out.println(m1(array)[1]);
}
public static int[] m1(int[][] m){
int[] result = new int[2];
result[0]= m.length;
result[1]= m[0].length;
return result;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!