Inheritance(Engineering > Computer Science And Engineering > C++ Language ) Questions and Answers

Question 1. What is meant by multiple inheritance?
  1.    Deriving a base class from derived class
  2.    Deriving a derived class from base class
  3.    Deriving a derived class from more than one base class
  4.    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?
  1.    Constructor and its destructor
  2.    Operator=() members
  3.    Friends
  4.    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?
  1.    Dot
  2.    Comma
  3.    Dollar
  4.    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?
  1.    Dynamic binding
  2.    Polymorphism
  3.    Both a & b
  4.    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?
  1.    class name
  2.    class name : access specifer
  3.    class name : access specifer class name
  4.    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++?
  1.    2
  2.    3
  3.    4
  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?
  1.    create a class
  2.    create a hierarchy of classes
  3.    access methods
  4.    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.    1
  2.    2
  3.    3
  4.    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?
  1.    class contains objects of other class types as its members
  2.    class contains objects of other class types as its objects
  3.    both a & b
  4.    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.    1
  2.    2
  3.    3
  4.    multiple
Explanation:-
Answer: Option D. -> multiple


There can be multiple constructors of the same class, provided they have different signatures.