In a layered application, which layer typically contains the high-level modules according to DIP?
Presentation Layer
Business Logic Layer
Data Access Layer
Database Layer
Which of these is NOT a potential consequence of violating the Liskov Substitution Principle?
Increased code complexity and reduced readability.
Higher likelihood of introducing bugs when extending or modifying code.
Improved performance due to optimized subclass implementations.
Decreased code reusability as subclasses may not behave as expected.
In the context of ISP, why are 'role interfaces' considered good practice?
They are specific to how a particular client uses a class, regardless of its primary responsibility.
They define a broad set of methods used by many unrelated classes.
They violate the Single Responsibility Principle.
They are only applicable to abstract classes, not interfaces.
How does the Interface Segregation Principle contribute to loose coupling in software design?
By encouraging the use of global variables for communication between classes.
By reducing the need for unit testing.
By promoting the use of concrete classes instead of interfaces.
By minimizing dependencies between classes to only what is absolutely necessary.
What could be a potential downside of excessively applying the Interface Segregation Principle?
It can lead to a higher number of interfaces, potentially increasing code complexity.
It reduces code reusability.
It makes the code more difficult to unit test.
It violates the principles of object-oriented programming.
What is the core idea behind the Interface Segregation Principle (ISP)?
Classes should have only one responsibility.
Code should be open for extension but closed for modification.
Subclasses should be substitutable for their base classes.
Clients should not be forced to depend on methods they don't use.
How does DIP relate to the concept of 'inversion of control'?
DIP and inversion of control are the same thing.
DIP is a specific implementation of inversion of control.
They are unrelated concepts.
Inversion of control is a specific implementation of DIP.
Which of the following scenarios most likely violates the Liskov Substitution Principle?
A subclass has more attributes than its superclass.
A subclass implements an interface that the superclass does not implement.
A subclass throws an exception that is not declared in the superclass's method signature.
A subclass overrides a method of its superclass and provides additional functionality.
Imagine a class named 'Employee' that handles both employee data (like name, ID) and database operations. What SOLID principle does this violate?
Single Responsibility Principle
Liskov Substitution Principle
Open/Closed Principle
Interface Segregation Principle
In the context of LSP, what is meant by 'substitutability'?
The capability to use a subclass object wherever a superclass object is expected without causing issues.
The idea that all methods in a subclass should be static.
The practice of always using abstract classes instead of concrete classes.
The ability to change the behavior of a superclass by modifying its subclass.