option
Cuestiones
ayuda
daypo
buscar.php

Decorator

COMENTARIOS ESTADÍSTICAS RÉCORDS
REALIZAR TEST
Título del Test:
Decorator

Descripción:
Information about Decorator Design

Fecha de Creación: 2025/11/25

Categoría: Ocio

Número Preguntas: 21

Valoración:(0)
COMPARTE EL TEST
Nuevo ComentarioNuevo Comentario
Comentarios
NO HAY REGISTROS
Temario:

What is the primary purpose of the Decorator Design Pattern?. To replace inheritance by permanently changing a class at compile time. To add responsibilities to individual objects dynamically without altering their interface. To create a single global object that controls access to resources.

The Decorator pattern primarily uses inheritance to add new behavior to objects. True. False.

Which statement about the Decorator pattern’s effect on the component’s interface is correct?. Decorators change the public interface of the component, requiring client code changes. Decorators preserve the component’s interface so clients remain unaware of added behaviors. Decorators remove methods from the component to simplify it.

A key motivation for the Decorator pattern is to avoid subclass explosion when you need many combinations of features. True. False.

Which of the following are typical participants in the Decorator pattern?. Component, ConcreteComponent, Decorator (abstract), ConcreteDecorator(s). Facade, SubsystemA, SubsystemB, Adapter. Builder, Director, Product.

Decorators can be stacked (one decorator wrapping another) to combine multiple behaviors. True. False.

When is the Decorator pattern the best choice?. When you need to add responsibilities to objects at runtime without affecting other objects and without creating many subclasses. When you need to enforce a single global instance (singleton) across the application. When you must convert one interface to another so two incompatible classes can work together.

What core problem does the Decorator pattern aim to solve?. The need to switch between multiple algorithms at runtime. The need to dynamically add behavior to individual objects without modifying their classes. The need to ensure only one instance of a class exists.

The Decorator pattern helps avoid creating a large, rigid inheritance hierarchy when adding new behavior. True. False.

Why is runtime flexibility a key motivation for using the Decorator pattern?. Because behavior can be added or removed while the program is running. Because the class must be modified every time a new feature is added. Because objects need to share global state.

Which scenario best illustrates the motivation for using decorators?. Converting data from XML to JSON. Adding features such as logging, caching, or compression to specific objects without changing their classes. Ensuring a class cannot be instantiated more than once.

One of the motivations of the Decorator pattern is to keep classes closed for modification but open for extension (OCP). True. False.

What design principle does the Decorator pattern strongly rely on to achieve its intent?. Composition over inheritance. Global state management. Tight coupling between classes.

Which of the following is a key motivation for choosing the Decorator pattern instead of subclassing?. To adapt one interface to another. To allow independent combination of behaviors without changing core classes. To hide complex subsystems behind a simpler interface.

What is the main structural relationship between a Decorator and the Component in the UML diagram?. The Decorator inherits from the ConcreteComponent. The Decorator implements the same interface (Component) and holds a reference to a Component. The Decorator replaces the Component entirely and does not interact with it.

In the Decorator UML, ConcreteDecorators inherit from the abstract Decorator class. True. False.

Which class in the Decorator UML diagram is responsible for providing the base behavior?. Component. ConcreteComponent. ConcreteDecorator.

In the UML structure, what does the Decorator class contain?. A list of all decorators in the system. A reference to the ConcreteComponent only. A reference to a Component (which could be another decorator or a concrete component).

The client interacts only with the Component interface, not with specific Decorators. True. False.

Which relationship does the UML diagram of Decorator demonstrate between the Decorator and Component classes?. Inheritance only. Composition + Inheritance. No relationship.

In the UML diagram, where is the new behavior added?. Inside the Component interface. Inside the ConcreteComponent class. Inside the ConcreteDecorator classes.

Denunciar Test