Review for Quiz 3

Question 3-1

Name and describe the eight primitive types included in Java.

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?

Solutions

Solution 3-1

byteinteger represented in 8 bits
shortinteger represented in 16 bits
intinteger represented in 32 bits
longinteger represented in 64 bits
floatfloating-point value in 32 bits
doublefloating-point value in 64 bits
charcharacter represented in 16 bits
booleana true/false value

Solution 3-2

2 3 5 3 5 3