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.
- How many Anthurium flowers were included in the first export consignment from Mizoram to Singapore?
On 07 August 2025 in New Delhi, declassified versions of which joint doctrines were released by the CDS?
According to the performance grading index (PGI) 2.0,which two states/ut have achieved Grade Prachesta -2 ?
_______ is appointed as the Interim President of Indian Olympic Association?
Who among the following has become the first ever Railway officer and also the first ever officer from the non-uniformed Civil Services to complete the ...
How much budget has been allocated for the extension of Pradhan Mantri Fasal Bima Yojana (PMFBY) and Restructured Weather Based Crop Insurance Scheme?...
Which country recently conducted a test of a new tactical ballistic missile called Hwasongpho-11 Da-4.5, designed to carry a 4.5-ton weapon?
The acceleration of the ocean current connecting the Indian, Atlantic, and Pacific oceans has been linked to which global condition?
Which of the following statements is/are not correct in regards to budget 2023-24?
1.   ‘Bharat Shared Repository of Inscriptions’ to be ...
How many Lok Sabha and State Assembly statistical reports can be generated through the Election Commission’s new Index Card system?