Interview Q&A / Object-Oriented Programming
Object-Oriented Programming interview questions
The four pillars, interfaces, abstract classes and design basics.
Prefer rapid revision? Practise Object-Oriented Programming short interview answers →
- What are the signs that code violates the Liskov Substitution Principle?
Subclasses that throw UnsupportedOperationException, override a method to do nothing, or callers that must check instanceof before using a parent-typed object.
IntermediateQuick answer1 min read - Why does Square extending Rectangle violate the Liskov Substitution Principle?
A Square must keep width and height equal, so setting one changes the other. Code written for any Rectangle, expecting independent sides, gets wrong results when given a Square.
IntermediateQuick answer1 min read