Challenge 2: A Generic Factory Using the new() Constraint — Possible Solution ==================================================================== Program.cs: class Widget { public string Label = "default widget"; } class Gadget { public int Count = 0; } static T CreateDefault() where T : new() { return new T(); } Widget w = CreateDefault(); Gadget g = CreateDefault(); Console.WriteLine(w.Label); Console.WriteLine(g.Count); Output: default widget 0 Explanation: The where T : new() constraint tells the compiler that whatever type T ends up being, it must have a public parameterless constructor -- this is what makes `new T()` legal at all inside CreateDefault(). Both Widget and Gadget satisfy this constraint (neither declares any constructor, so each gets an implicit public parameterless one), so CreateDefault() and CreateDefault() both compile and run, constructing a genuine new instance of whichever type was requested. WHY THIS WORKS AS AN ANSWER ------------------------------ This implements the exact new()-constrained generic factory the chapter introduces, calling it successfully with two different types, directly demonstrating the capability java2-1's own Challenge 2 named as impossible under Java's erasure.