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.
Find the wrong number in the given number series.
41, 51, 63, 80, 101, 126
Find the Wrong number in the given number series.
137, 148, 190, 261, 361, 490- Find the wrong number in the given number series.
91, 103, 125, 163, 211, 271 Find the wrong number in the given number series.
15, 38, 67, 98, 135, 181
850, 849, 841, 814, 750, 688
Direction: Find the wrong number in given number series.
1977, 1945, 1837, 1575, 1081, 217.
- Find the wrong number in the given number series.
3, 6, 10, 15, 21, 29 Find the wrong term in the following series:
2, 4, 8, 14, 24, 32, 44
Find the wrong number in the given number series.
- 342, - 218, - 96, 27, 150, 273
Find the wrong number in the given number series.
26, 38, 60, 110, 206, 398