Computer » Programming Languages

Which of the following enables an object , variable or a method in OOPs to take multiple forms?

A

Inheritance

B

Polymorphism

C

Encapsulation

D

Abstraction

Solution

Polymorphism : It is a OOPs concept that is refers the ability of an object/variable/method  to take multiple forms.

Example: "Animal" class has different sub-classes like horse, fish, tiger etc. "Animal" class has one method called "Move" which will be defined in different ways in subclasses.

Like when for "horse" class it will be as "trotting" while for "Fish" class it will be "Swimming".

Inheritance : It refers to the ability of subclass to inherit features of the parent class. It leads to helps re-usability of code.

Encapsulation : It refers to binding of methods/variables/objects of one class together.

Abstraction : It refers to the hiding of the data.

Generalization : It refers to grouping of subclasses into one class. Like Permanent faculty and Guest