Question: what is the difference between inheritance and delegation illustrate with example?
Answer: Delegation vs Inheritance in Java. ... Delegation is simply passing a duty off to someone/something else. Delegation can be an alternative to inheritance. Delegation means that you use an object of another class as an instance variable, and forward messages to the instance.