Q. What is the output of the following code?
Code:
int[] arr = new int[]{1, 2, 3, 4, 5};
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
β
Correct Answer: (A)
1 2 3 4 5
Explanation: The for loop iterates over each element of the array and prints its value.