Crowdly
Додати до Chrome
Questions Bank (1461554 total)
In the GoF Adapter pattern structure, what role represents the existing class with an incompatible interface that needs adapting?
Client
0%
Target
0%
Component
0%
Adaptee
✅
Переглянути це питання
In the Decorator pattern, what is the responsibility of the abstract Decorator class?
To validate user inputs before passing them to the operating system.
0%
To instantiate concrete components using factory methods.
0%
To implement the Component interface and forward all requests to its wrapped Component instance by default.
✅
To define concrete business logic and prevent subclasses from modifying behavior.
0%
Переглянути це питання
Consider the code: new BufferedReader(new FileReader("file.txt")). What role does BufferedReader play in this construct?
AbstractSubject
0%
ConcreteComponent
0%
ConcreteDecorator
0%
Adaptee
❌
Переглянути це питання
Which method from java.util.Arrays acts as an Adapter between an array and the List collection interface?
Arrays.binarySearch()
0%
Arrays.copyOf()
0%
Arrays.sort()
0%
Arrays.asList()
✅
Переглянути це питання
Why is the Decorator pattern often favored over deep class inheritance hierarchies?
Inheritance requires all methods to be final, whereas Decorators support polymorphism.
0%
Decorators execute significantly faster than static method dispatch in the JVM.
0%
Inheritance prevents subclasses from accessing protected parent methods.
0%
Decorators avoid an explosion of static subclasses required to cover all feature combinations.
✅
Переглянути це питання
Can multiple instances of the same ConcreteDecorator be chained together in Java?
Yes, but only if the Component interface declares the Cloneable interface.
0%
Yes, because each decorator treats the wrapped object uniformly as the Component type.
0%
No, chaining the same decorator causes an immediate StackOverflowError at instantiation.
❌
No, the compiler prevents multiple decorators of the same type from nesting.
0%
Переглянути це питання
What happens to the interface of the wrapped object in the Decorator pattern from the client's perspective?
It converts all checked exceptions into unchecked runtime exceptions.
0%
It is completely hidden and replaced by an incompatible interface.
0%
It exposes all internal private helper methods of the wrapped component.
0%
It remains transparent and identical to the Component interface, so clients do not notice the wrapping.
✅
Переглянути це питання
Which class in the standard java.io package serves as a classic example of the Adapter pattern by bridging byte streams to character streams?
BufferedInputStream
❌
InputStreamReader
0%
FilterInputStream
0%
DataOutputStream
0%
Переглянути це питання
In Java GUI programming, what does a class like java.awt.event.WindowAdapter primarily provide?
A wrapper that converts mouse events into keyboard events dynamically.
0%
Default empty implementations for all methods in the WindowListener interface.
0%
A bridge between AWT components and Swing rendering engines.
❌
Automatic synchronization for multithreaded UI events.
0%
Переглянути це питання
In Java, why is the Object Adapter pattern generally preferred over the Class Adapter pattern?
Java interfaces cannot declare methods with signatures matching third-party classes.
0%
Java does not support multiple class inheritance, preventing an adapter from extending multiple concrete classes.
✅
Class Adapters are deprecated since Java 8 with the introduction of default methods.
0%
Object Adapters offer faster runtime performance than Class Adapters due to JVM optimizations.
0%
Переглянути це питання
Попередня
1
Більше сторінок
1232
1233
1234
1235
1236
Більше сторінок
146156
Наступна
Telegram
Instagram
TikTok
Question Bank
Умови використання
Зв'яжіться з нами
Додати до Chrome