Challenge 3: A Bounded Generic smaller() Method — Possible Solution ==================================================================== BoundedDemo.java: public class BoundedDemo { public static > T smaller(T a, T b) { return a.compareTo(b) < 0 ? a : b; } public static void main(String[] args) { System.out.println(smaller(7, 3)); System.out.println(smaller("banana", "apple")); } } Output: 3 apple Explanation: `T extends Comparable` restricts T to only those types that implement Comparable -- both Integer (via autoboxing, java1-2) and String satisfy this, since both provide a real compareTo() method. Because of that bound, the compiler can verify a.compareTo(b) is a legitimate call at compile time, for ANY type T is eventually filled in with -- it doesn't need to wait until runtime to find out whether compareTo() exists, and it would reject a type that doesn't implement Comparable before the code ever runs. WHY THIS WORKS AS AN ANSWER ------------------------------ This uses the exact bounded-type-parameter pattern the chapter introduces, and demonstrates it working correctly with two genuinely different types (Integer and String), showing the compile-time safety the bound provides despite erasure still applying underneath.