Question: Which of the following code segments will correctly print all elements of a 2 D int array called arr? I. for ( int i =

Which of the following code segments will correctly print all elements of a 2D int array called arr?
I. for (int i =0; i < arr.length; i++){ for (int j =0; j < arr.length; j++){
System.out.println(arr[i][j]);
}
System.out.println();
}
II. for (int[] x : arr){
for (int j =0; j < x.length; j++){
System.out.println(x[j]);
}
System.out.println();
}
III. for (int[] i : arr){ for (int j : i){
System.out.println(arr[i][j]);
}
System.out.println();
}
(A) I only (B) II only (C) III only (D) I and II (E) I and III

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 Databases Questions!