Question: Consider the following code segment. int [ ] arr = { 1 , 2 , 4 , 0 , 3 } ; for ( int

Consider the following code segment.
int[] arr ={1,2,4,0,3};
for (int i : arr)
{
System.out.print(i);
}
Which of the following code segments will produce the same output as the code segment above?
I.
int[] arr ={1,2,4,0,3};
for (int i : arr)
{
System.out.print(arr[i]);
}
II.
int[] arr ={1,2,4,0,3};
for (int i =0; i < arr.length; i++)
{
System.out.print(i);
}
III.
int[] arr ={1,2,4,0,3};
for (int i =0; i < arr.length; i++)
{
System.out.print(arr[i]);
}
Responses
I only
I only
III only
III only
I and II only
I and II only
I and III only
I and III only
I, II, 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!