All challenges
Multiple ChoiceHard 45s

Deep inheritance hierarchies

A four-level inheritance hierarchy forces subclasses to override methods they do not need and to know about unrelated parent behavior. What is the best refactor direction?
Options
  1. 1Add more intermediate base classes to share behavior
  2. 2Push all behavior into the root class so nothing is overridden
  3. 3Make every method abstract so subclasses must implement everything
  4. 4Replace the hierarchy with composition and small focused interfaces used where needed

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle