Q. What is the output of the following code?
Code:
int[] myArray = {1, 2, 3, 4, 5};
for (int i = 0; i < myArray.length; i++) {
System.out.print(myArray[i] + ” “);
}
β
Correct Answer: (A)
1 2 3 4 5
Explanation: The for loop iterates through each element of the array and prints its value, followed by a space.