Question
Which SOLID principle ensures that a class has only one
reason to change?Solution
The Single Responsibility Principle (SRP) states that a class should have only one reason to change, meaning it should have only one responsibility or function. This principle promotes cohesion by ensuring each class handles a specific part of the software functionality. For instance, a Customer class should handle customer data, while an Invoice class manages invoice generation. Adhering to SRP simplifies debugging, enhances maintainability, and prevents interdependent changes from cascading through the codebase. Why Other Options Are Incorrect :
- Open/Closed Principle : This emphasizes that classes should be open for extension but closed for modification, unrelated to SRP.
- Liskov Substitution Principle : This ensures that derived classes can replace base classes without altering program correctness.
- Dependency Inversion Principle : This recommends high-level modules should not depend on low-level modules but rather on abstractions.
- Interface Segregation Principle : This advises against forcing a class to implement interfaces it does not use, unrelated to SRP.
The minimum value of 25 sin2 θ + 16 cos2 θ is
- If 2cosec 2 A – cot 2 A = 5 and 0 o < A < 90 o , then find the value of ‘A’.
- If sec 2P = sin² 60⁰ + sec 60⁰ - cos² 30⁰, then determine the value of (√3tan P + cot² P)
(tan 5x - tan 3x - tan 2x) = ?
If cot8A = tan(A+8˚), find the value of A? Given that 8A and A+8 are acute angles.
If (3cos A - sin A) = 2 cos (90° - A), then find the value of cot A.
Two points P and Q are at the distance of x and y (where y > x) respectively from the base of a building and on a straight line. If the angles of elevat...
If sec x + tan x = 11 then find secx?