In: Computer Science
Which Feature of OOP illustrates code reusability? Abstraction, Encapsulation, Inheritance, Polymorphism or All of them.
Answer: The correct answer is Inheritance.
Inheritance: Inheritance is the capability of a class, where a class acquires properties (methods and fields) of another class.
Abstraction: Abstraction is one of the important features of object-oriented programming. Abstraction means hide complexity and display only essential details to the user. Abstraction is implemented using abstract classes and interfaces.
Encapsulation: Encapsulation means binding data and methods together.
Example: Class, In the class variables and methods bundled together under a class name.
Polymorphism: Polymorphism means having many forms. Polymorphism allows a message to be displayed in many forms. Polymorphism could be implemented at compile time and at run time. Method overloading, Operator overloading, virtual functions all come under polymorphism.
So the correct answer is Inheritance.