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.
The code “oth” represents which of the following word?
In a certain code language, ‘CELEBRATE’ is coded as ‘BVKVAQZSV’, then ‘DIFFERENT’ will be coded as ____ in the same code language.
...Which of the following can be coded as 'sp rq lm sm'
In a certain code, NUMERAL, is written as MMURELA. How is ' PROJECT' written in that code?
RKEHXO
In a certain code language, STATION is coded as 21-22-3-22-11-17-16, and CRUEL is coded as 5-20-23-7-14. How will VIXEN be coded in that language?
In a certain code language, ‘APPLY’ is coded as ‘ZTTPC’ and ‘MOUSE’ is coded as ‘QNTWD’. How will ‘LIGHTS’ be coded as in that langu...
Which of the following of coded as ‘pik’?
KHPCVB
What is the ode for “nation” in the given code language?