Type Here to Get Search Results !

In OOP, what does the term "composition over inheritance" mean?

0

 In OOP, what does the term "composition over inheritance" mean?

A) Using inheritance as the primary way to achieve code reuse.
B) Preferring composition to create complex types instead of relying solely on class hierarchies.
C) Avoiding the use of classes altogether.
D) Using multiple inheritance exclusively.

Answer: B) Preferring composition to create complex types instead of relying solely on class hierarchies.

Explanation: "Composition over inheritance" is a design principle that suggests favoring composition (combining simple objects or classes) to build complex types rather than relying solely on class inheritance. This approach promotes flexibility and reduces tight coupling between classes, making systems easier to change and extend.

Post a Comment

0 Comments