Challenge 2: A Checked Exception, Uncaught and Undeclared — Possible Solution ==================================================================== Broken attempt — FileDemo.java: import java.nio.file.Files; import java.nio.file.Path; public class FileDemo { public void readFile(String path) { // no throws, no try/catch Files.readAllBytes(Path.of(path)); } } Representative compile error: FileDemo.java:5: error: unreported exception IOException; must be caught or declared to be thrown Files.readAllBytes(Path.of(path)); ^ 1 error Fixed — FileDemo.java: import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; public class FileDemo { public void readFile(String path) throws IOException { Files.readAllBytes(Path.of(path)); } } Explanation: Files.readAllBytes declares that it can throw the checked exception IOException. Because IOException is checked (an Exception subtype that isn't a RuntimeException), the compiler refuses to compile any method that calls it without either catching IOException directly or declaring throws IOException on the calling method itself, passing the obligation up to ITS caller instead. WHY THIS WORKS AS AN ANSWER ------------------------------ This reproduces the exact compiler-enforced requirement the chapter describes for checked exceptions -- a real compile error, not a runtime failure -- and resolves it using the throws clause, the "side-channel" acknowledgment the chapter contrasts against Rust's Result living directly in the return type.