Question
Which design pattern is best suited for managing the
creation of objects without specifying their concrete classes?Solution
The Factory Pattern is a creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created. It abstracts the instantiation process, enabling flexibility and scalability in object creation. For instance, in a GUI framework, the factory method might create different types of buttons (WindowsButton, MacButton) depending on the operating system. By decoupling the client code from concrete classes, this pattern promotes adherence to the Open/Closed Principle of SOLID. Why Other Options Are Incorrect :
- Singleton Pattern : This ensures a class has only one instance and provides global access to it, unrelated to flexible object creation.
- Observer Pattern : This defines a one-to-many dependency, where changes in one object are notified to multiple observers.
- Adapter Pattern : This works as a bridge between incompatible interfaces, not for object creation.
- Decorator Pattern : This adds functionality dynamically to objects, without modifying their structure.
Which of the following bank has become the first public sector bank to go live on Income Tax Department's new Direct Tax Collection System Tin 2.0?
Giddha dance is a folk dance of which of the following states?
Which species of green algae, commonly known as stonewort, is often mistaken for a plant?
Which of the following is not correct about Pradhan Mantri Kisan Samman Nidhi (PM-KISAN):
Under which Amendment to the Constitution Act was the reservation for OBCs in educational institutions made?
The cost of cultivating a square field at the rate of ₹320 per hectare is ₹2880. Find its area. (Use 1 hectare = 10000 sq.m)
Which of the following states hosts the annual Surajkund crafts fair?
Which of the following metal was not used in a special commemorative Rs 75 coin to mark the opening of the new Parliament building?
By observing the motion of objects on an inclined plane ______ deduced that objects move with a constant speed when no force acts on them.
Which IPL player-team pairing is correctly matched for IPL 2024? Â