Recall & Review
beginner
What does the Single Responsibility Principle (SRP) state?
SRP means a class should have only one reason to change, meaning it should have only one job or responsibility.Click to reveal answer
intermediate
What is a common violation of the Open/Closed Principle (OCP)?
Changing existing code to add new features instead of extending it. This makes the system fragile and hard to maintain.
Click to reveal answer
intermediate
How can the Liskov Substitution Principle (LSP) be violated?
When a subclass changes the expected behavior of the parent class, causing errors when used in place of the parent.Click to reveal answer
beginner
What does the Interface Segregation Principle (ISP) recommend?
Clients should not be forced to depend on interfaces they do not use. Use many small, specific interfaces instead of one large one.
Click to reveal answer
intermediate
How does the Dependency Inversion Principle (DIP) improve design?
By depending on abstractions (interfaces) rather than concrete classes, making the system flexible and easier to change.
Click to reveal answer
Which SOLID principle is violated if a class handles multiple unrelated tasks?
✗ Incorrect
A class with multiple unrelated tasks violates SRP because it has more than one reason to change.
What is a fix for violating the Open/Closed Principle?
✗ Incorrect
Extending classes allows adding new features without changing existing code, respecting OCP.
If a subclass breaks the behavior expected from its parent, which principle is violated?
✗ Incorrect
LSP requires subclasses to be substitutable for their parents without altering expected behavior.
What does Interface Segregation Principle encourage?
✗ Incorrect
ISP encourages small, focused interfaces so clients only depend on what they use.
Dependency Inversion Principle suggests depending on:
✗ Incorrect
DIP promotes depending on abstractions to reduce coupling and increase flexibility.
Explain how you would fix a class that violates the Single Responsibility Principle.
Think about dividing jobs like splitting household chores among family members.
You got /3 concepts.
Describe how the Dependency Inversion Principle helps in making a system easier to maintain.
Imagine using a universal remote that works with many devices instead of a fixed one.
You got /3 concepts.