In SOLID, what does the L stand for?

Get ready for your Object‑Oriented Programming Test. Use flashcards and multiple-choice questions. Each question includes hints and explanations. Prepare for your exam today!

Multiple Choice

In SOLID, what does the L stand for?

Explanation:
Liskov Substitution Principle says that you should be able to replace a base class with its derived classes without changing the correctness of the program. In practice this means a subclass must honor the contract of the base type: it should not require stronger preconditions or promise weaker postconditions than the base type. If code relies on a base type interface, substituting a subclass instance should behave identically from the caller’s perspective. A common example is a shape with a method to compute area; a subclass should not alter the guarantees of that method in a way that surprises users who expect the base type’s behavior. If a subclass imposes extra constraints or changes outcomes, substitutability is broken. The other SOLID principles address different design goals: Open-Closed encourages extending behavior via new code rather than modifying existing code, Interface Segregation advises splitting large interfaces into smaller, client-specific ones, and Dependency Inversion focuses on depending on abstractions rather than concrete implementations.

Liskov Substitution Principle says that you should be able to replace a base class with its derived classes without changing the correctness of the program. In practice this means a subclass must honor the contract of the base type: it should not require stronger preconditions or promise weaker postconditions than the base type. If code relies on a base type interface, substituting a subclass instance should behave identically from the caller’s perspective. A common example is a shape with a method to compute area; a subclass should not alter the guarantees of that method in a way that surprises users who expect the base type’s behavior. If a subclass imposes extra constraints or changes outcomes, substitutability is broken. The other SOLID principles address different design goals: Open-Closed encourages extending behavior via new code rather than modifying existing code, Interface Segregation advises splitting large interfaces into smaller, client-specific ones, and Dependency Inversion focuses on depending on abstractions rather than concrete implementations.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy