asked in Inheritance by (58.6k points)

1 Answer

Inheritance is used for code reuse and leveraging Polymorphism by creating a type hierarchy. It's better to use Inheritance for type declaration but for code reuse composition is a better option because it's more flexible. See this article for learning more about why Composition is better than Inheritance.
answered by (58.6k points)

Java Interview Questions and Answers 2018