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 is a covariant return type in method overriding?
An overriding method may return a more specific type (a subclass) than the parent's method declared. Callers using the child type then avoid casting.
AdvancedQuick answer1 min read - What rules must an overriding method follow to respect the Liskov Substitution Principle?
It must accept at least what the parent accepts, promise at least what the parent promises, and throw no new kinds of failure. Weaker preconditions, stronger postconditions, same invariants.
AdvancedQuick answer1 min read