Explain the difference between Factory Method and Abstract Factory patterns.?
- Factory Method: Defines an interface for creating an object but lets subclasses
decide which class to instantiate. It uses inheritance and relies on subclass
overriding.
- Abstract Factory: Provides an interface to create families of related or dependent
objects without specifying their concrete classes. It uses composition and is useful
when you need to create multiple related objects together.