Inheritance lets us to leverage Dynamic binding and code reuse.
Composition lets us make use of the delegation, it happens like this, the caller can always call the front end class,it in turn calls the backed class. The advantage of composition is it provides stronger encapsulation compared to inheritance( we do not need to make any changes to the call, if the back end class's signature/return type changes.
Composition lets us make use of the delegation, it happens like this, the caller can always call the front end class,it in turn calls the backed class. The advantage of composition is it provides stronger encapsulation compared to inheritance( we do not need to make any changes to the call, if the back end class's signature/return type changes.