Skip to main content

Practice · 5 of 5

Reference semantics under misdirection (E4)

CHALLENGE
Difficulty: advanced+25 XP

Trace this program **on paper**: ``java public static void adjust(int[] a, int[] b, int k) { a[0] += k; // mutation of the shared array b = new int[3]; // local rebinding b[0] += k; // lost k = 99; // lost } int[] x = {1, 2}; int[] y = {3, 4}; int k = 5; adjust(x, y, k); System.out.print(x[0] + "," + y[0] + "," + k); `` Return the printed text exactly.

Back to lesson: Practice: Trace drills: state tables and misdirection