What is the benefit of Composition over Inheritance?



What is the benefit of Composition over Inheritance?..

Answer / Vinay Vishal

Composition offers better modularity, flexibility, and extensibility because it allows creating objects with specific behavior without inheriting unwanted properties from other classes. With inheritance, you are forced to use methods that may not be useful or appropriate for your specific needs.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOAD Interview Questions

What is operator overloading and polymorphism?

1 Answers   ITC Indian Tobacco Company,


Can we use static method definitions in interfaces?

1 Answers  


How many methods do u implement if implement the serializable interface?

1 Answers  


What is static and dynamic Binding?

1 Answers  


What is a pure virtual function?

4 Answers  


How to differentiate between a CreateObject() and GetObject() ?

1 Answers   CGI,


Can encapsulation be called as a security device?

1 Answers  


A class inherits from 2 interfaces and both the interfaces have the same method name as shown below. How should the class implement the drive method for both car and bus interface?

1 Answers  


What's the benefit of using inheritance?

1 Answers  


Explain about inheritance hierarchies?

1 Answers  


Can an interface inherit from another interface?

1 Answers  


What is the benefit of using inheritance?

1 Answers  


Categories