Skip to content
Sharp

Object-oriented programming · interview question

Which design principle is violated if a class hierarchy is built based on shared implementation details rather than shared behavior?

Multiple choiceMediumchapter-5-curatedpremiumoopcomposition-vs-inheritance
Choose one answer
Answer and explanation

Correct answer

A. Liskov Substitution Principle

Why

The Liskov Substitution Principle is violated when subclasses are not truly substitutable for their superclass due to focusing on shared implementation details instead of behavior. This can lead to unexpected behavior and brittle code.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →