Question 51
MediumWhich pattern provides a single simple interface to a complex subsystem, such as one method to place an order that calls inventory, payment and shipping?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Object-Oriented Programming
Which pattern provides a single simple interface to a complex subsystem, such as one method to place an order that calls inventory, payment and shipping?
Observer
Adapter
Facade
Decorator
Sign up free to see the answer and a step-by-step explanation.
Which pattern creates objects without the client naming the concrete class, such as ShapeFactory.create("circle")?
Decorator
Observer
Strategy
Factory Method / Simple Factory
Sign up free to see the answer and a step-by-step explanation.
Which pattern guarantees a class has only one instance and gives global access to it?
Builder
Singleton
Adapter
Prototype
Sign up free to see the answer and a step-by-step explanation.
Which pattern builds a complex object step by step, such as new Pizza.Builder().size("L").cheese().build()?
Prototype
Builder
Factory Method
Composite
Sign up free to see the answer and a step-by-step explanation.
Which design pattern lets you add behaviour to individual objects at run time by wrapping them, without changing their class?
Singleton
Factory Method
Adapter
Decorator
Sign up free to see the answer and a step-by-step explanation.
Which design pattern defines a family of interchangeable algorithms and lets the client choose one at run time?
Strategy
Prototype
Observer
Builder
Sign up free to see the answer and a step-by-step explanation.
Which pattern notifies a list of dependent objects automatically when a subject's state changes?
Command
Observer
Facade
Strategy
Sign up free to see the answer and a step-by-step explanation.
What does the Law of Demeter (principle of least knowledge) recommend?
Prefer deep inheritance
Use global variables for sharing
Every class should know every other class
An object should talk only to its immediate collaborators, avoiding chains like a.getB().getC().doX()
Sign up free to see the answer and a step-by-step explanation.
Which pair describes good modular design?
Low cohesion and low coupling
Low cohesion and high coupling
High cohesion and low coupling
High cohesion and high coupling
Sign up free to see the answer and a step-by-step explanation.
Which pattern converts the interface of an existing class into one that clients expect, so incompatible classes can work together?
Proxy
Adapter
Decorator
Composite
Sign up free to see the answer and a step-by-step explanation.