CS FundamentalsHardProduct-company design interview
A document-editor framework defines an abstract Application class with a method newDocument() that calls createDocument(); each concrete app (TextApp, DrawingApp) overrides createDocument() to return its own document type. Which pattern is this?
- A. Abstract Factory
- B. Factory Method
- C. Builder
- D. Prototype
Correct answer: B. Factory Method
Factory Method lets subclasses decide which class to instantiate through an overridable creation method used by the base class's own logic. Abstract Factory is a separate object creating a family of products.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- An object adapter and a class adapter both make class Legacy fit interface Target. Which statement is correct?
- Both Facade and Mediator sit between groups of objects. What is the essential difference?
- A Customer may or may not have a discount policy. Instead of writing if policy is not None: total = policy.apply(total) everywhere, the…
- Which form of dependency injection makes required dependencies explicit and allows the object to be immutable and fully initialised as…
- A message broker delivers each message at least once, so consumers sometimes see duplicates (for example after a crash before an ack). A…
- Match the delivery guarantee. P: the consumer acks a message before processing it. Q: the consumer acks only after processing succeeds. R…