Challenge 1: Iterating a HashMap and a Missing-Key Lookup — Possible Solution ==================================================================== MapDemo.java: import java.util.HashMap; import java.util.Map; public class MapDemo { public static void main(String[] args) { Map ages = new HashMap<>(); ages.put("Alice", 30); ages.put("Bob", 25); ages.put("Carol", 41); for (Map.Entry entry : ages.entrySet()) { System.out.println(entry.getKey() + " -> " + entry.getValue()); } System.out.println("Missing key result: " + ages.get("Dave")); } } Output (HashMap iteration order is not guaranteed, so entry order may vary): Alice -> 30 Bob -> 25 Carol -> 41 Missing key result: null Explanation: entrySet() returns a Set of Map.Entry objects, each supplying getKey()/getValue(), giving a genuinely iterable view of the map's pairs. ages.get("Dave") returns null rather than throwing, since "Dave" was never put into the map -- get() on a missing key simply reports "no value found" via null, not an exception. WHY THIS WORKS AS AN ANSWER ------------------------------ This uses entrySet() exactly as the chapter demonstrates for iteration, and shows get()'s real behavior on a missing key (null, not an exception), a detail worth confirming explicitly rather than assuming.