(Implementation) inheritance creates a static, compile-time is-a relationship in which the subclass automatically receives — and can be affected by — the ENTIRE public and protected interface of its superclass, including operations irrelevant or even harmful to the subclass's own abstraction. This is exactly the "message leakage" problem: a Stack implemented by extending List inherits insertAt(index)/removeAt(index), letting client code bypass the Stack's push/pop discipline entirely and violate its own invariant.
Delegation (composition plus forwarding) creates a runtime has-a relationship: the using class holds a private reference to an instance of the used class and explicitly forwards only the specific operations it chooses to expose through its own interface — the used object's full interface never leaks through.
When delegation is necessary in place of inheritance:
When the is-a relationship doesn't actually hold in the LSP sense (Question 11) — the subclass cannot honestly satisfy the superclass's full contract without weakening it.
When only a PARTIAL subset of the superclass's interface is wanted or appropriate — the Stack-via-List message-leakage case above; delegation lets the class expose only push()/pop()/peek(), hiding insertAt/removeAt entirely.
When the relationship needs to change at RUNTIME — which object is delegated to can be swapped after construction, while inheritance's is-a binding is fixed at compile time; this is precisely the mechanism behind the Strategy pattern (Question 15) and the Object Adapter variant (Question 14).
When avoiding tight coupling to a superclass's IMPLEMENTATION details across a fragile-base-class boundary — a change to the superclass's internals can silently break subclasses that rely on its exact behaviour in ways delegation's narrower forwarding interface never exposes.
Left: inheritance leaks List's full interface into Stack. Right: delegation exposes only push/pop/peek, forwarding internally to a private List.