Question 3-2

Consider the following static method.

public static void mystery(int[] arr) {
    for(int i = 3; i < arr.length; i++) arr[i] = arr[i - 2];
    for(int i = 0; i < arr.length; i++) {
        IO.print(" " + arr[i]);
    }
}
Suppose we were to pass the array { 2, 3, 5, 7, 11, 13 } into this method. What would the method print?

Solution

2 3 5 3 5 3

Back to Review for Quiz 3