Factory method pattern enables us to create an object without exposing the creation logic to the client and refer to the newly-created object using a common interface. It is one of the most widely used creational patterns. This pattern is also known as the Virtual Constructor. The intent of this pattern, according to Design Patterns by Gamma et al, is to: Define an interface for creating an object, but let subclasses decide which class to instantiate. The Factory method allows a class to defer instantiation to subclasses. The Factory method is for creating objects. A superclass specifies all standard and generic behavior and then delegates the creation details to subclasses…