public static void modify(int[] arr) {
arr[0] = 99;
arr = new int[]{1, 2, 3};
arr[1] = 50;
}
public static int caller() {
int[] x = {10, 20, 30};
modify(x);
return x[0] + x[1];
}
// Call: System.out.println(caller());What is printed?
- Acheck_circle
119
- B
51
- C
30
- D
120
Explanation
arr[0]=99 mutates x[0]. Reassigning arr locally doesn't affect x. So x = {99,20,30}. 99+20 = 119.