C++ Programming - OOPS Concepts - Discussion

Discussion :: OOPS Concepts - General Questions (Q.No.56)


Which of the following provides a reuse mechanism?

[A]. Abstraction
[B]. Inheritance
[C]. Dynamic binding
[D]. Encapsulation

Answer: Option B


No answer description available for this question.

Harish said: (Jul 15, 2012)  
Through inheritance, we can acquire the properties of the parent class. Thus we can reuse the methods and variables of the parent class.

Harjot said: (Nov 23, 2014)  
Inheritance allows the programmer to make use of the features of one class to make another sub-class. For example, 'Pigeon' reuses or inherits some features from the class 'Bird'.

Abstraction is said to be in effect when the user is provided with only the useful information, hiding the rest. For instance, a user doesn't need to know how the class 'Pigeon' is stored in the memory - all s/he cares about it how different is 'Pigeon' from 'Peacock'.

Encapsulation allows us to wrap data and functions that will use that data, into a single unit such as a Class. A class for creating a 'Bird' would have all the data and the functions related to this class.

Polymorphism is the property by which any entity can behave differently when a different message is passed to them. One set of parameters in the class 'Bird' can you a 'Pigeon', another can give you a 'Peacock'.

Tomxie said: (Jan 11, 2017)  
Why not Abstraction?

Pranali said: (Jun 20, 2018)  
easy to test

Mau said: (Jul 16, 2019)  
It can acquire the properties of another class so, inheritance provides reuse mechanism.

Codi said: (Sep 7, 2021)  
Thank you @Harjot.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.