Problem Statement
Factory Method solves which problem in object creation?
Explanation
Factory Method lets a base class call a creation hook while subclasses decide the concrete type. This removes explicit new calls from high-level code.
It improves testability and keeps open–closed extension. You add a new product by adding a new subclass, not by changing callers.
Code Solution
SolutionRead Only
interface Transport { deliver(): void }
abstract class Logistics { factory(): Transport; }
class ShipLogistics extends Logistics { factory(){ return new Ship(); } }