JAVA DESIGN PATTERN Questions and Answers

Mention when to use a Factory Pattern?

Factory pattern can be used,

  • When a class does not know which class of objects needs to create
  • When class specifies its sub-classes to specify which objects to create
  • In programming language, you can use factory pattern where you have to create an object of any one of sub-classes depending on the given data