Review for Quiz 3

One-page version suitable for printing.

Question 3-1

Name and describe the eight primitive types included in Java.

Solution

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