Inheritance(Engineering > Computer Science And Engineering > C++ Language ) Questions and Answers
Question 1. What is meant by multiple inheritance?
Deriving a base class from derived class
Deriving a derived class from base class
Deriving a derived class from more than one base class
None of the mentioned
Explanation:-
Answer: Option C. -> Deriving a derived class from more than one base class
Multiple inheritance enables a derived class to inherit members from more than one parent.
Question 2. What are the things are inherited from the base class?
Constructor and its destructor
Operator=() members
Friends
All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned
These things can provide necessary information for the base class to make a logical decision.
Question 3. Which symbol is used to create multiple inheritance?
Dot
Comma
Dollar
None of the mentioned
Explanation:-
Answer: Option B. -> Comma
For using multiple inheritance, simply specify each base class (just like in single inheritance), separated by a comma.
Question 4. Which of the following advantages we lose by using multiple inheritance?
Dynamic binding
Polymorphism
Both a & b
None of the mentioned
Explanation:-
Answer: Option C. -> Both a & b
The benefit of dynamic binding and polymorphism is that they help making the code easier to extend but by multiple inheritance it makes harder to track.
Question 5. What is the syntax of inheritance of class?
class name
class name : access specifer
class name : access specifer class name
None of the mentioned
Explanation:-
Answer: Option C. -> class name : access specifer class name
class name : access specifer class name
Question 6. How many types of inheritance are there in c++?
2
3
4
5
Explanation:-
Answer: Option D. -> 5
There are five types of inheritance in c++. They are single, Multiple, Hierarchical, Multilevel, Hybrid.
Question 7. What does inheriatance allows you to do?
create a class
create a hierarchy of classes
access methods
None of the mentioned
Explanation:-
Answer: Option B. -> create a hierarchy of classes
create a hierarchy of classes
Question 8. How many types of constructor are there in C++?
1
2
3
4
Explanation:-
Answer: Option C. -> 3
There are three types of constructor in C++. They are Default constructor, Parameterized constructor, Copy constructor.
Question 9. What is meant by containership?
class contains objects of other class types as its members
class contains objects of other class types as its objects
both a & b
none of the mentioned
Explanation:-
Answer: Option A. -> class contains objects of other class types as its members
class contains objects of other class types as its members
Question 10. How many constructors can present in a class?
1
2
3
multiple
Explanation:-
Answer: Option D. -> multiple
There can be multiple constructors of the same class, provided they have different signatures.