Question 0-4

Consider the following class method.

public static void mystery(int[] arr) {
    for(int i = arr.length - 1; i > 0; i--) {
        arr[i] = 10 + arr[i - 1];
    }
    for(int i = 0; i < arr.length; i++) {
        IO.print(arr[i]);
    }
}
Suppose we were to pass the array { 1, 4, 5 } into this method. What would the method print?

Solution

11114

Back to Review for Midterm 0