What is the core idea behind the Liskov Substitution Principle (LSP)?
Code should be open for extension, but closed for modification.
Subtypes should be substitutable for their base types without altering the correctness of the program.
Classes should have only one responsibility.
Interfaces should be small and focused on a single task.
How can you identify multiple responsibilities within a class?
By checking if the class name is too long.
By looking for different reasons to change the class in the future.
By counting the number of lines of code in the class.
By observing how many other classes it interacts with.
Which of these is NOT a benefit commonly associated with applying the Dependency Inversion Principle?
Improved testability
Increased code complexity
Enhanced code reusability
Reduced code coupling
Which of these is a benefit of adhering to the Single Responsibility Principle?
More complex class design for handling multiple tasks.
Tighter coupling between classes for better collaboration.
Reduced code duplication and improved reusability.
Increased class size for better code organization.
What is a key benefit of having high-level modules depend on abstractions?
It simplifies the low-level modules.
It reduces the number of lines of code.
It makes the high-level module reusable with different implementations.
It improves code readability.
Which of these techniques can help achieve the Open/Closed Principle?
Using abstract classes and interfaces.
Hardcoding values directly into classes.
Avoiding the use of design patterns.
Copying and pasting code to create new functionality.
SOLID principles primarily aim to improve which aspect of software development?
Memory Optimization
Algorithm Efficiency
Execution Speed
Code Maintainability
Which of the following best describes the Dependency Inversion Principle (DIP)?
Low-level modules should depend on high-level modules.
High-level modules should depend on low-level modules.
Both high-level and low-level modules should depend on abstractions.
Abstractions should depend on concrete implementations.
Which of the following best describes the impact of SRP on code testability?
SRP has no significant impact on the ease or difficulty of writing unit tests.
SRP makes it more complex to write unit tests as classes have intertwined functionalities.
SRP makes unit testing easier as classes are smaller and have well-defined responsibilities.
SRP makes it impossible to write unit tests as it encourages separation of concerns.
How can you identify potential violations of the Liskov Substitution Principle in your code?
By only using abstract classes and interfaces.
By looking for instances where a subclass throws an exception not declared in the superclass or introduces behavior that breaks the superclass's contract.
By avoiding inheritance altogether and favoring composition.
By ensuring all methods in subclasses are static.