answers 100% correct 2025
Strategy - correct answer ✔Defines a family of algorithms, encapsulates
each one, makes them interchangeable.
Lets the algorithm vary independently from clients that use it
Encapsulate interchangeable behaviors and use delegation to decide which
behavior to use
Observer - correct answer ✔one-to-many dependency between objects so
that when one object changes state, all of its dependents are modified and
updated automatically
loosely coupled
Decorator - correct answer ✔Attaches additional responsibilities to an object
dynamically. Provide a flexible alternative to subclassing for extending
functionality
Behavior extended without modifying existing code
involves a set of decorator classes that are used to wrap concrete
components
mirror the type of the components they decorate
, change the behavior of their components by adding new functionality before
and/or after (or even in place of) method calls to the component.
typically transparent to the client of the component
don't alter interface, but adds responsibility
Factory - correct answer ✔Defines an interface for creating an object, but
lets subclasses decide which class to instantiate
encapsulate object creation
simple way to decouple clients from concrete classes
relies on inheritance: object creation is delegated to subclasses which
implement the ____ method to create objects
relies on object composition: object creation is implemented in methods
exposed in the ____ interface
promote loose coupling by reducing dependency of your application on
concrete classes
ALLOW CLASS TO DEFER INSTANTIATION TO ITS SUBCLASSES
abstract ____ method is to create families of related objects without having to
depend on their concrete classes