Crowdly
Додати до Chrome
Questions Bank (1461554 total)
What is a well-known drawback of using the Decorator pattern?
It prevents objects from being garbage collected once decorated.
0%
It violates the Single Responsibility Principle by packing multiple duties into one class.
❌
It makes code harder to debug due to numerous small objects and deeply nested delegation chains.
0%
It cannot be combined with interfaces in modern Java.
0%
Переглянути це питання
In the Decorator pattern, what structural relationship must exist between the Decorator and the Component interface?
The Decorator must be a subclass of the ConcreteComponent and override all its private fields.
0%
The Decorator must extend Object directly and delegate via reflection.
0%
The Decorator must have no type relationship with the Component to ensure loose coupling.
0%
The Decorator implements or extends the Component interface and maintains a reference to a Component instance.
✅
Переглянути це питання
Which wrapper method from java.util.Collections acts as a Decorator by adding thread-safety synchronization to an existing list?
Collections.emptyList()
0%
Collections.singletonList()
0%
Collections.unmodifiableCollection()
0%
Collections.synchronizedList()
✅
Переглянути це питання
How does the Decorator pattern affect object identity comparisons (==) in Java?
A decorated object is not reference-identical (==) to the underlying component, which can break identity-dependent code.
✅
The JVM automatically merges references for decorators implementing the same interface.
0%
It has no effect because the decorator and wrapped component share the exact same reference.
0%
The Decorator pattern forces equals() and hashCode() to always throw an UnsupportedOperationException.
0%
Переглянути це питання
What is the main design distinction between the Adapter and Facade patterns?
Adapter changes an existing interface to match a target, while Facade provides a simplified interface to a subsystem.
✅
Adapter is a behavioral pattern, while Facade is a structural pattern.
0%
Adapter creates new behavior, while Facade converts existing method signatures.
0%
Adapter works only with single instances, while Facade works only with abstract factories.
0%
Переглянути це питання
What is the primary intent of the Adapter design pattern according to the Gang of Four (GoF)?
To provide a unified interface to a set of interfaces in a subsystem.
0%
To ensure a class only has one instance and provide a global point of access to it.
0%
To convert the interface of a class into another interface that clients expect.
✅
To dynamically attach additional responsibilities to an object at runtime.
0%
Переглянути це питання
Which class hierarchy in the Java Standard Library extensively utilizes the Decorator pattern?
java.math (e.g., BigInteger, BigDecimal, MathContext)
0%
java.io (e.g., InputStream, BufferedInputStream, GZIPInputStream)
✅
java.util.concurrent (e.g., ExecutorService, Future, Callable)
0%
java.lang.reflect (e.g., Method, Field, Constructor)
0%
Переглянути це питання
What is the primary intent of the Decorator design pattern?
To attach additional responsibilities to an object dynamically as an alternative to subclassing.
✅
To convert an existing object's interface so that another class can interact with it.
0%
To encapsulate a request as an object, thereby letting you parameterize clients with different requests.
0%
To define a family of algorithms, encapsulate each one, and make them interchangeable.
0%
Переглянути це питання
How does an Object Adapter typically invoke functionality on the Adaptee?
Through object composition by maintaining a reference to the Adaptee and delegating method calls.
✅
By creating a proxy subclass of the Adaptee using dynamic proxies.
0%
Through multiple inheritance of state and behavior.
0%
By modifying the bytecode of the Adaptee using reflection at runtime.
0%
Переглянути це питання
You have a legacy payment processing class with method makePayment(int cents). Your new architecture requires an interface PaymentGateway with process(BigDecimal dollars). Which design pattern is most appropriate to integrate the legacy class?
Adapter Pattern
✅
State Pattern
0%
Decorator Pattern
0%
Composite Pattern
0%
Переглянути це питання
Попередня
1
Більше сторінок
1231
1232
1233
1234
1235
Більше сторінок
146156
Наступна
Telegram
Instagram
TikTok
Question Bank
Умови використання
Зв'яжіться з нами
Додати до Chrome