CS FundamentalsHardGATE CS · TCS NQT Prime · Product Company SDE

A graphics application needs to create a new shape by copying an existing, fully-configured one (rather than re-specifying every property from scratch), including cases where the exact concrete class isn't known at compile time. Which pattern fits?

  1. A. Composite pattern
  2. B. Prototype pattern
  3. C. Builder pattern
  4. D. Factory Method pattern

Correct answer: B. Prototype pattern

Prototype clones an existing, already-configured object to produce a new one, which is useful exactly when creating a fresh instance from scratch would be expensive or when the concrete type is only known at run time.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic