Wrapper Classes FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

A ferry booth stores unused stickers.

(a) Write Java that starts with int printed = 16; then Integer held = printed; then int shown = held; (b) State the values of held and shown. (c) Identify which assignment autoboxes and which unboxes. (d) State whether Integer requires an import.

Question 2 of 5

A bakery ticker reads counts from text.

(a) Write int muffins = Integer.parseInt("24"); and double glaze = Double.parseDouble("1.5"); (b) State the values of muffins + 1 and glaze + 0.5. (c) Identify the return types of parseInt and parseDouble from the Java Quick Reference. (d) Explain why Integer boxed = Integer.parseInt("24"); still compiles.

Question 3 of 5

Complete the missing cells for a lighthouse blink counter. Then explain why blinks = blinks + 2; does not change one Integer object in place.

Step Statement blinks raw
1 Integer blinks = 7; 7 not created
2 blinks = blinks + 2; not created
3 int raw = blinks;
4 raw += 1;

Question 4 of 5

A pottery studio uses wrapper parameters.

public class Studio {
    public int triple(Integer n) {
        return n * 3;
    }
    public void reset(Integer n) {
        n = 0;
    }
}

Integer heat = 5; and Studio s = new Studio(); are already constructed. (a) State the value returned by s.triple(heat). (b) After s.reset(heat); state heat. (c) Explain the unboxing in triple. (d) Explain why reset does not change heat.

Question 5 of 5

A shed shelves integer bin tags. Trace the boxing, then explain immutability. Do not write an ArrayList algorithm.

import java.util.ArrayList;
ArrayList<Integer> bins = new ArrayList<Integer>();
bins.add(4);
Integer first = bins.get(0);
int copy = first;
first = 9;

(a) State bins.get(0) and copy after these statements. (b) Explain the autoboxing in add(4). (c) Explain why first = 9 does not change the list element. (d) State that Integer objects are immutable.