Java OCA OCP Practice Question 398

Question

Which statements indicate the need to use the factory pattern?

Choose all that apply.

  • A. You don't want the caller to depend on a specific implementation
  • B. You have two classes that do the same thing
  • C. You only want one instance of the object to exist
  • D. You want one class to be responsible for database operations
  • E. You want to build a chain of objects


A is correct.

Note

The factory design pattern decouples the caller from the implementation class name.

B is incorrect because that would be poor design.

C is incorrect because it describes the singleton pattern.

D is incorrect because it describes the DAO pattern.

E is incorrect because of the above.




PreviousNext

Related