Question 1 of 10
A kiln logs unused glaze batches in a wrapper variable. What text does this Java code display?
Integer batches = 14;
System.out.print(batches);
- A. null
- B. 14
- C. Integer
- D. a compile-time error
A kiln logs unused glaze batches in a wrapper variable. What text does this Java code display?
Integer batches = 14;
System.out.print(batches);
A tram unboxes leftover tokens before subtracting two. What text does this Java code display?
Integer tokens = 9;
int leftover = tokens;
System.out.print(leftover - 2);
A marina kiosk reads a slip number from text. What text does this Java code display?
int slip = Integer.parseInt("26");
System.out.print(slip + 4);
A tide board parses a meter reading from text. What text does this Java code display?
double meters = Double.parseDouble("3.25");
System.out.print(meters + 1);
A booth stamps a primitive ticket code into a wrapper parameter. What text does this Java code display?
public class Booth {
public void stamp(Integer code) {
System.out.print(code + 5);
}
}
int raw = 8;
Booth b = new Booth();
b.stamp(raw);
A lantern count is updated with arithmetic on a wrapper. What text does this Java code display?
Integer lanterns = 6;
lanterns = lanterns + 4;
System.out.print(lanterns);
Two ferry counters start as aliases, then one wrapper variable is reassigned. What text does this Java code display?
Integer east = 5;
Integer west = east;
east = 11;
System.out.print(east + "," + west);
A harbor method reassigns its Integer parameter. What text does this Java code display?
public class Harbor {
public void bump(Integer n) {
n = n + 1;
}
}
Integer slips = 4;
Harbor h = new Harbor();
h.bump(slips);
System.out.print(slips);
A crate list autoboxes int values when they are added. What text does this Java code display?
import java.util.ArrayList;
ArrayList<Integer> crates = new ArrayList<Integer>();
crates.add(3);
crates.add(12);
int first = crates.get(0);
System.out.print(first + crates.get(1));
A weather kiosk labels each conversion. Using the table, which label is wrong?
| Statement | Student label |
|---|---|
| Integer p = 20; | autoboxing |
| int k = p; | unboxing |
| double x = Double.parseDouble("1.5"); | autoboxing |
| Double d = 2.0; | autoboxing |