Documente Academic
Documente Profesional
Documente Cultură
🔗Source: www.educba.com
new HardDisk250GBFilter(),
new MacintoshFilter(),
new I5ProcessorFilter());
🔗Source: tutorialspoint.com
🔗Source: sitepoint.com
🔗Source: stackoverflow.com
🔗Source: stackoverflow.com
🔗Source: tutorialspoint.com
🔗Source: stackoverflow.com
Q9: Explain difference between the Facade,
Proxy, Adapter and Decorator design patterns?
Topic: Design Patterns
Difficulty: ⭐⭐⭐⭐⭐
🔗Source: stackoverflow.com
Powered by Translate
Ensure that only one instance of a class exists at the same time.
B.
The correct answer is A. The Singleton pattern ensures that no more than one
instance of the class exists ever.
It does not allow one instance of the Singleton to be destroyed and then another one
created. In general, a Singleton has nothing to do with separating objects in different
classes. A Singleton does control creation of objects, but not in a single or another
class.
o A.
Factory Method
o B.
Abstract Factory
o C.
Builder
o D.
Prototype
2.
Attach additional responsibilities to an object dynamically. It provides a
flexible alternative to subclassing for extending functionality.
o A.
Chain of responsibility
o B.
Adapter
o C.
Decorator
o D.
Composite
3.
Define a family of algorithms, encapsulate each one, and make them
interchangeable. It lets the algorithm vary independently from clients that
use it.
o A.
Template method
o B.
Decorator
o C.
Strategy
o D.
Visitor
4.
Define one too many dependencies between objects so that when one
object changes state, all its dependencies are notified and updated
automatically.
o A.
Chain of responsibility
o B.
Event Notification
o C.
Mediator
o D.
Observer
5.
Encapsulate a request as an object, thereby letting you parametrize clients
with different requests, queue or log requests, and support undoable
operation.
o A.
Adapter
o B.
Command
o C.
Decorator
o D.
Composite
6.
Ensure a class has only one instance, and provide a global access point to
it.
o A.
o B.
Proxy
o C.
Singleton
o D.
Flyweight
7.
Define the skeleton of an algorithm in an operation, deferring some steps to
subclasses. It lets subclasses redefine certain steps of an algorithm without
changing the algorithm structure.
Discuss
o A.
Chain of responsibility
o B.
Template method
o C.
Interpretor
o D.
Prototype
8.
Provide a unified interface to a set of interfaces in a subsystem. It defines a
higher level interface that makes the subsystem easier to use.
o A.
Facade
o B.
Mediator
o C.
Adapter
o D.
Strategy
9.
Provides a way to access the elements of an aggregate object sequentially
without exposing its underlying representation.
o A.
Iterator
o B.
Visitor
o C.
Composite
o D.
Command
10.
Which of the following is correct about the Singleton design pattern.
o A.
o B.
This pattern involves a single class which is responsible to create an object while
making sure that only single object gets created.
o C.
Singleton class provides a way to access its only object which can be accessed
directly without need to instantiate the object of the class
o D.
Proxy
Singleton
Flyweight
Define the skeleton of an algorithm in an operation, deferring
some steps to subclasses. It lets subclasses redefine certain
steps of an algorithm without changing the algorithm
structure.
Chain of responsibility
Template method
Interpretor
Prototype
A. Chain of responsibility
B. Adapter
C. Decorator
D. Composite
Difficulty: Easy91% got this correct
Incorrect Discuss this Question
2) Ensure a class has only one instance, and provide a global access point to it.
A. Facade
B. Mediator
C. Adapter
D. Strategy
Related Qu
Correct Difficulty: Easy64% got this correct
1) Defines an interface for creating an object, but let the subclasses decide which class to
instantiate. It let the instantiation differ to subclasses.
A. Factory Method
B. Abstract Factory
C. Builder
D. Prototype
Correct Difficulty: Easy74% got this correct
2) Define a family of algorithms, encapsulate each one, and make them interchangeable. It
lets the algorithm vary independently from clients that use it.
A. Template method
B. Decorator
C. Strategy
D. Visitor
Correct Difficulty: Easy78% got this correct
3) Define one too many dependencies between objects so that when one object changes state, all
its dependencies are notified and updated automatically.
A. Chain of responsibility
B. Event Notification
C. Mediator
D. Observer
Difficulty:
Correct Easy75%
got this
correct
4) Encapsulate a request as an object, thereby letting you parametrize clients with different
requests, queue or log requests, and support undoable operation.
A. Adapter
B. Command
C. Decorator
D. Composite
Correct Difficulty: Easy70% got this correct
5) Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. It
lets subclasses redefine certain steps of an algorithm without changing the algorithm
structure.
A. Chain of responsibility
B. Template method
C. Interpretor
D. Prototype
Correct Difficulty: Easy72% got this correct
6) Provides a way to access the elements of an aggregate object sequentially without exposing
its underlying representation.
A. Iterator
B. Visitor
C. Composite
D. Command
Correct Difficulty: Easy63% got this correct
7) Which of the following is correct about the Singleton design pattern.