public class Helper {
public static void fill(int[] a) {
a[0] = 99;
}
}
// ...
int[] arr = {1, 2, 3};
Helper.fill(arr);
System.out.println(arr[0]);What is printed?
- Acheck_circle
99
- B
1
- C
0
- D
Compile-time error
Explanation
Arrays are reference types; the method modifies the same array object, so arr[0] becomes 99.