Question 8-3

[5 pts] Suppose we were to execute the following run() method.

public class Question3 {
  public static int[] f(int[] arr) {
    arr = new int[arr.length];
    for(int i = 0; i < arr.length; i++) {
      arr[i] = 2 * i;
    }
    return arr;
  }
  public static void run() {
    int[] a = { 9, 8, 7 };
    int[] b = f(a);
    IO.println(a[1]);
    IO.println(b.length);
    IO.println(b[1]);
  }
}
What would it print?

Solution

8
3
2

Back to 8:00 Quiz 8