Question
Which SOLID principle emphasizes that a class should
have only one reason to change?Solution
The Single Responsibility Principle (SRP) in SOLID design principles states that a class should have only one reason to change, meaning it should encapsulate only one responsibility. This principle promotes cohesion and ensures that each class handles a single task or functionality. For instance, in an inventory management system, a Product class should handle product-related data only, while a separate Inventory class manages stock levels. Adhering to SRP reduces complexity, makes code easier to understand, and simplifies debugging and testing. By isolating responsibilities, developers can introduce changes without affecting unrelated parts of the system. Why Other Options Are Incorrect :
- Open/Closed Principle : Focuses on extending classes without modifying existing code, not on single responsibility.
- Liskov Substitution Principle : Ensures that derived classes can be substituted for their base classes without breaking functionality.
- Dependency Inversion Principle : Encourages dependency on abstractions rather than concrete implementations, unrelated to single responsibilities.
- Interface Segregation Principle : Suggests splitting large interfaces into smaller, specific ones, focusing on interface design, not class responsibilities.
If 50 percent of the families in a certain city subscribe to the morning newspaper, 65 percent of the families subscribe to the afternoon newspaper and ...
The 'Special Drawing Right (SDR)' is an international reserve asset created by:
What is the primary theme of India’s Union Budget 2024-25?"
The Mundell-Fleming framework studies (A) _____ , (B) _________ economies in a world with (C) _____ financial markets and (D) _____ capital mobility
Which among the following are the recommendations of the Urjit Patel Committee report on monetary policy?
I. Curtailment of the fiscal deficit.
Under the Bretton wood system, the long-term development assistance was to be provided by
-
IBRD
...
-
If rxy = 0.75, then ryx will be:

When a firm operates with excess capacity