351. Identify the problem of GoF pattern: How to obtain the power of polymorphism when reusing a class whose methods have the same function but not the same signature as the other methods in the hierarchy?
Adapter
Singleton
Façade
Delegation
Show me the answer
Answer: 1. Adapter
Explanation:
The Adapter pattern allows a class to be reused even if its methods do not match the expected interface, enabling polymorphism by adapting the interface of one class to another.
352. Identify the problem of GoF pattern: How do you simplify the view that programmers have of a complex package?
Adapter
Singleton
Façade
Delegation
Show me the answer
Answer: 3. Façade
Explanation:
The Façade pattern simplifies the view of a complex package by providing a unified interface to a set of interfaces in a subsystem, making it easier to use.
353. ______ represent the best practices used by experienced object-oriented software developers.
EB2
IMS
Design Patterns
JCL
Show me the answer
Answer: 3. Design Patterns
Explanation:
Design Patterns represent the best practices used by experienced object-oriented software developers to solve common design problems.
354. GOF stands for?
Gamma of four
Gang of four
Gang of helm
Gamma of helm
Show me the answer
Answer: 2. Gang of four
Explanation:
GOF stands for Gang of Four, referring to the four authors (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) who wrote the book "Design Patterns: Elements of Reusable Object-Oriented Software."
355. Design patterns can be classified in ______ categories.
1
2
3
4
Show me the answer
Answer: 3. 3
Explanation:
Design patterns are classified into three categories: Creational, Structural, and Behavioral patterns.
356. Which design patterns are specifically concerned with communication between objects?
Creational Patterns
Structural Patterns
Behavioral Patterns
J2EE Patterns
Show me the answer
Answer: 3. Behavioral Patterns
Explanation:
Behavioral patterns are concerned with communication between objects and how they interact to achieve a common goal.
357. Which pattern are identified by Sun Java Center?
Adapter pattern
Creational pattern
Behavioral Patterns
J2EE Patterns
Show me the answer
Answer: 4. J2EE Patterns
Explanation:
J2EE Patterns are identified by Sun Java Center and are specifically designed for Java Enterprise Edition (J2EE) applications.
358. Factory pattern is one of most used design pattern in Java.
TRUE
FALSE
Can be true or false
Can not say
Show me the answer
Answer: 1. TRUE
Explanation:
The Factory pattern is one of the most commonly used design patterns in Java, as it provides a way to create objects without specifying the exact class of the object that will be created.
359. In how many steps Singleton class in java created?
1
2
3
4
Show me the answer
Answer: 2. 2
Explanation:
A Singleton class in Java is typically created in two steps: (1) making the constructor private and (2) providing a static method to access the single instance of the class.
360. ______ works as a bridge between two incompatible interfaces.
Builder pattern
Adapter pattern
Bridge pattern
Memento pattern
Show me the answer
Answer: 2. Adapter pattern
Explanation:
The Adapter pattern works as a bridge between two incompatible interfaces, allowing them to work together by converting the interface of one class into another interface that clients expect.
361. Filter pattern also known as?
Visitor pattern
Composite pattern
Filter pattern
Iterator pattern
Show me the answer
Answer: 3. Filter pattern
Explanation:
The Filter pattern is also known as the Criteria pattern, which is used to filter objects based on certain criteria.
362. Can we create a clone of a singleton object?
Yes
No
Can be yes or no
Can not say
Show me the answer
Answer: 1. Yes
Explanation:
It is possible to create a clone of a Singleton object, but it defeats the purpose of the Singleton pattern, which is to ensure that only one instance of the class exists.
363. You want to avoid multiple inheritance. Which design pattern would you choose?
Abstraction-Occurrence Pattern
Player-Role Pattern
General Hierarchy Pattern
Singleton Pattern
Show me the answer
Answer: 2. Player-Role Pattern
Explanation:
The Player-Role Pattern is used to avoid multiple inheritance by allowing an object to dynamically take on different roles without inheriting from multiple classes.
364. The recurring aspects of designs are called design
Patterns
Documents
Structures
Methods
Show me the answer
Answer: 1. Patterns
Explanation:
Design patterns are recurring solutions to common problems in software design. They represent best practices and are used to solve design issues efficiently.
365. Design pattern is a solution to a problem that occurs repeatedly in a variety of contexts.
True
False
Show me the answer
Answer: 1. True
Explanation:
Design patterns are solutions to recurring problems in software design. They provide a template for solving common issues in a variety of contexts.
366. Which pattern prevents one from creating more than one instance of a variable?
Factory Method
Singleton
Observer
None of the mentioned
Show me the answer
Answer: 2. Singleton
Explanation:
The Singleton pattern ensures that only one instance of a class is created and provides a global point of access to that instance.
367. Facade pattern promotes weak coupling between subsystem and its clients.
True
False
Show me the answer
Answer: 1. True
Explanation:
The Facade pattern promotes weak coupling by providing a simplified interface to a complex subsystem, reducing the dependencies between the subsystem and its clients.
368. Which design pattern defines one-to-many dependency among objects?
State pattern
Adapter Pattern
Observer pattern
Factory method pattern
Show me the answer
Answer: 3. Observer pattern
Explanation:
The Observer pattern defines a one-to-many dependency among objects, where a change in one object (the subject) triggers updates in all its dependents (observers).
369. Facade pattern couples a subsystem from its clients.
True
False
Show me the answer
Answer: 2. False
Explanation:
The Facade pattern does not couple a subsystem from its clients; instead, it provides a simplified interface to the subsystem, reducing coupling.
370. In factory method pattern, the framework must instantiate classes but it only knows about the abstract classes, which it cannot initiate. How would one solve this problem?
Encapsulating the knowledge of which document subclass to is to be created and
Moving this knowledge out of the framework
Instantiating the application specific documents without knowing their class
All of the mentioned
Show me the answer
Answer: 4. All of the mentioned
Explanation:
The Factory Method pattern solves the problem by encapsulating the knowledge of which subclass to create, moving this knowledge out of the framework, and allowing the framework to instantiate application-specific documents without knowing their exact class.
371. Which mechanism is applied to use a design pattern in an OO system?
Inheritance
Composition
All of the mentioned
None of the mentioned
Show me the answer
Answer: 3. All of the mentioned
Explanation:
Both inheritance and composition are mechanisms used to implement design patterns in an object-oriented system. Inheritance allows for code reuse, while composition allows for flexible object relationships.
372. Design patterns does not follow the concept of software reuse.
True
False
Show me the answer
Answer: 2. False
Explanation:
Design patterns are based on the concept of software reuse. They provide reusable solutions to common design problems, promoting code reuse and maintainability.
373. The use of design patterns for the development of object-oriented software has important implications for ______.
Component-based software engineering
Reusability in general
All of the mentioned
None of the mentioned
Show me the answer
Answer: 3. All of the mentioned
Explanation:
The use of design patterns has important implications for both component-based software engineering and reusability in general. They promote modularity, flexibility, and code reuse.
374. Which of the following is a design pattern?
Behavioral
Structural
Abstract Factory
All of the mentioned
Show me the answer
Answer: 4. All of the mentioned
Explanation:
Behavioral, Structural, and Abstract Factory are all design patterns. Behavioral patterns deal with object interaction, Structural patterns deal with object composition, and Abstract Factory is a creational pattern.
375. You want to minimize development cost by reusing methods? Which design pattern would you choose?
Adapter Pattern
Singleton Pattern
Delegation pattern
Builder Pattern
Show me the answer
Answer: 3. Delegation pattern
Explanation:
The Delegation pattern allows you to reuse methods by delegating tasks to other objects, minimizing development costs and promoting code reuse.
376. Which of the following is the correct list of entities of Composite Entity pattern?
The Composite Entity pattern consists of Composite Entity, Coarse-Grained Object, and Dependent Object. These entities work together to represent a complex object structure.
377. Which of the following describes the Behavioral pattern correctly?
This type of patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator
This type of patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
This type of pattern are specifically concerned with communication between objects.
This type of pattern are specifically concerned with the presentation tier.
Show me the answer
Answer: 3. This type of pattern are specifically concerned with communication between objects.
Explanation:
Behavioral patterns are concerned with communication between objects and how they interact to achieve a common goal. They focus on object collaboration and responsibility distribution.
378. Which of the following is correct about Abstract Factory design pattern.
This type of design pattern comes under creational pattern.
Abstract Factory patterns work around a super-factory which creates other factories.
In Abstract Factory pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes.
All of the above.
Show me the answer
Answer: 4. All of the above.
Explanation:
The Abstract Factory pattern is a creational pattern that provides an interface for creating families of related objects without specifying their concrete classes. It works around a super-factory that creates other factories.
379. Which of the following pattern refers to creating duplicate object while keeping performance in mind?
Proxy Pattern
Composite Pattern
Prototype Pattern
Facade Pattern
Show me the answer
Answer: 3. Prototype Pattern
Explanation:
The Prototype Pattern is used to create duplicate objects while keeping performance in mind. It allows objects to be cloned without knowing their specific classes.
380. Which of the following pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance?
Iterator Pattern
Observer Pattern
Flyweight Pattern
Visitor Pattern
Show me the answer
Answer: 3. Flyweight Pattern
Explanation:
The Flyweight Pattern is used to reduce the number of objects created, decrease memory footprint, and increase performance by sharing objects that are similar in nature.
381. GRASP stands for ______.
Global responsibility assignment software patterns
General responsibility assignment software patterns
General responsibility assignment system patterns
General research assignment software patterns
Show me the answer
Answer: 2. General responsibility assignment software patterns
Explanation:
GRASP stands for General Responsibility Assignment Software Patterns. It provides guidelines for assigning responsibilities to classes and objects in object-oriented design.
382. There are ______ GRASP patterns.
7
8
9
10
Show me the answer
Answer: 3. 9
Explanation:
There are 9 GRASP patterns: Creator, Information Expert, Low Coupling, High Cohesion, Controller, Polymorphism, Pure Fabrication, Indirection, and Protected Variations.
383. Which GRASP pattern is suitable to handle alternatives based on type?
Indirection
Pure fabrication
Polymorphism
Creator
Show me the answer
Answer: 3. Polymorphism
Explanation:
The Polymorphism pattern is suitable for handling alternatives based on type. It allows different classes to respond to the same message in different ways.
384. Which GRASP pattern helps to find out answer for “Who should be responsible for creating a new instance of some class?”
Adapter
Protected variations
Creator
Controller
Show me the answer
Answer: 3. Creator
Explanation:
The Creator pattern helps determine which class should be responsible for creating a new instance of another class. It is based on the principle that a class that contains or aggregates another class should be responsible for creating instances of that class.
385. You want all the clients using class A to use the same instance of class A, what should you do to achieve this goal?
Override a method of class A
Mark class a abstract
Apply the singleton pattern to class “A”
Apply the command pattern to class “A”
Show me the answer
Answer: 3. Apply the singleton pattern to class “A”
Explanation:
The Singleton pattern ensures that only one instance of a class is created and provides a global point of access to that instance. This ensures that all clients use the same instance of class A.
386. Which design pattern you would you use to have a prototypical instance determine the concrete class of object being created?
Prototype factory design pattern
Virtual prototype design pattern
Non-abstract prototype design pattern
Prototype design pattern
Show me the answer
Answer: 4. Prototype design pattern
Explanation:
The Prototype design pattern allows a prototypical instance to determine the concrete class of the object being created. It involves cloning an existing object rather than creating a new one from scratch.
387. Which Design Pattern should you use when you want to parameterize objects by an action to perform?
Command
Prototype
Memento
Iterator
Show me the answer
Answer: 1. Command
Explanation:
The Command pattern is used to parameterize objects by an action to perform. It encapsulates a request as an object, allowing for parameterization of clients with different requests, queuing of requests, and logging of requests.
388. Which design pattern you would you use to decouple the creation procedure of a complex object from its concrete instance to be able to apply that procedure on variety of implementations.
Factory builder design pattern
Method builder design pattern
Builder design pattern
Observer method design pattern
Show me the answer
Answer: 3. Builder design pattern
Explanation:
The Builder design pattern is used to decouple the creation procedure of a complex object from its concrete instance. It allows the same construction process to create different representations of the object.
389. Which Design Pattern should you use when you want to represent part-whole hierarchies of objects?
Composite
Decorator
Adapter
State
Show me the answer
Answer: 1. Composite
Explanation:
The Composite pattern is used to represent part-whole hierarchies of objects. It allows clients to treat individual objects and compositions of objects uniformly.
390. Given the following scenario: You want to create families of related objects, to be used interchangeably to configure you application. What is most appropriate GoF pattern to use?
Mediator
Abstract factory
Visitor
Iterator
Show me the answer
Answer: 2. Abstract factory
Explanation:
The Abstract Factory pattern is used to create families of related objects that can be used interchangeably to configure an application. It provides an interface for creating families of related or dependent objects without specifying their concrete classes.
391. When would you use the GOF Decorator design pattern?
To translate an existing class interface into a compatible target interface
To assign more functionality to an object without sub-classing it
To decouple an abstraction from its implementation so that the two can vary independently
To nest layers of decorators to add more functionality
Show me the answer
Answer: 2. To assign more functionality to an object without sub-classing it
Explanation:
The Decorator pattern is used to add additional functionality to an object dynamically without sub-classing. It allows for flexible extension of object behavior at runtime.
392. When would you use the GOF Composite design pattern?
To decouple an abstraction from its implementation so that the two can vary independently
To translates an existing class interface into a compatible target interface
To arrange object hierarchies such that the client code can access both the individual objects and compositions in a uniform manner
To improve the system overall performance
Show me the answer
Answer: 3. To arrange object hierarchies such that the client code can access both the individual objects and compositions in a uniform manner
Explanation:
The Composite pattern is used to arrange object hierarchies so that clients can treat individual objects and compositions of objects uniformly. It is useful for representing part-whole hierarchies.
393. ______ are the consequences of applying the GOF Singleton pattern.
It introduces thread safety issue when the singleton instance is instantiated on demand
The client code can creates multiple instances at run time
It reduces of the class hierarchy as compared to the other factory design patterns
It makes it easier for a certain family of objects to work together
Show me the answer
Answer: 1. It introduces thread safety issue when the singleton instance is instantiated on demand
Explanation:
One of the consequences of applying the Singleton pattern is that it can introduce thread safety issues when the singleton instance is instantiated on demand. Proper synchronization mechanisms must be used to ensure thread safety.
394. ______ describes the Builder pattern correctly.
This pattern builds a complex object using simple objects and using a step by step approach.
This pattern refers to creating duplicate object while keeping performance in mind.
This pattern is used when creation of object directly is costly.
This pattern is used when we need to decouple an abstraction from its implementation so that the two can vary independently.
Show me the answer
Answer: 1. This pattern builds a complex object using simple objects and using a step by step approach.
Explanation:
The Builder pattern builds a complex object using simple objects and follows a step-by-step approach. It separates the construction of a complex object from its representation, allowing the same construction process to create different representations.
395. ______ is not one of the elements of a design pattern.
Content
Environment
Problem
Solution
Show me the answer
Answer: 1. Content
Explanation:
The elements of a design pattern include the problem, solution, and environment. Content is not considered one of the core elements of a design pattern.
396. Which GOF design pattern is applied in the code snippet below?
Proxy design pattern
Singleton design pattern
Façade design pattern
Abstract singleton design pattern
Show me the answer
Answer:
Singleton design pattern
Explanation:
The code snippet implements the Singleton design pattern, which ensures that only one instance of the PrintSpooler class is created and provides a global point of access to that instance.
Can send a message
Cannot send a message
May send a message
Can’t send a message because Register and ProductCatalog are instance of a class
Show me the answer
Answer: 1. Can send a message
Explanation:
Since the Register class has a reference to the ProductCatalog, it can send a message to it. This is an example of visibility in object-oriented design.
public class PrintSpooler {
private static final PrintSpooler INSTANCE = new PrintSpooler();
private PrintSpooler() {
public static PrintSpooler getInstance() {
return INSTANCE;
}
}
}