Programming MCQs

Top 20 MCQ Questions On Inheritance In C++

Pinterest LinkedIn Tumblr

Here are the collections of top 20 MCQ questions on inheritance in C++ includes multiple-choice questions about inheritance and their types, single inheritance, multiple inheritances, multilevel inheritance, hierarchical inheritance along with base and derived classes. It also includes about constructors in derived classes and virtual base classes.

1. The ……………. inherits some or all of the properties of the ……….. class.
A) base, derived
B) derived, base
C) derived, initial
D) base, final

2. A derived class with only one base class is called …………… inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical

3. A class can inherit properties from more than one class which is known as ……….inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical

4. A class can be derived from another derived class which is known as ………. inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical

5. When the properties of one class are inherited by more than one class, which is called ……… inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical

6. When a base class is privately inherited by a derived class public members of the base class become ………. of the derived class.
A) private members
B) protected members
C) Public members
D) Not inherited

7. When a base class is privately inherited by derived class public members of the base class can only be accessed by the ……… of the derived class.
A) non-member functions
B) friend functions
C) member functions
D) class members

8. When a protected member is inherited in public mode, it becomes ……….. in the derived class too and therefore is accessible by member functions of the derived class.
A) protected
B) private
C) public
D) friend

9. State whether the following statements about inheritance are True or False.
i) A public member of a class can be accessed by its own objects using the dot operator.
ii) While inheriting, the private members of the base class will never become members of its derived class.
A) True, False
B) False, True
C) True, True
D) False, False

10. A member declared as ………….. is accessible by the member functions within its class and any class immediately derived from it.
A) protected
B) private
C) public
D) friend

11. When the base class is publicly inherited, public members of the base class become …………. of the derived class.
A) private members
B) protected members
C) Public members
D) Not inherited

12. In the protected derivation, both the public and protected members of the base class become …………. members of the derived class.
A) protected
B) private
C) public
D) friend

13. What will be the order of execution of base class constructors in the following method of inheritance?
class A: public B, public C {….};
A) B(); C(); A();
B) C(); B(); A();
C) A(); B(); C();
D) B(); A(); C();

14. What will be the order of execution of base class constructors in the following method of inheritance?
class A: public B, virtual public C {….};
A) B(); C(); A();
B) C(); B(); A();
C) A(); B(); C();
D) B(); A(); C();

15. While the friend functions and the member functions of a friend class can have direct access to both the private and protected data, the member functions of a derived class can directly access only the ………… data.
A) protected
B) private
C) public
D) friend

16. In ……………………. inheritance, the constructors are executed in the order of inheritance.
A) multipath
B) multiple
C) multilevel
D) hierarchical

17. In ……………….. inheritance, the base classes are constructed in the order in which they appear in the deceleration of the derived class.
A) multipath
B) multiple
C) multilevel
D) hierarchical

18. ……………….. inheritance may lead to duplication of inherited members from a ‘grandparent’ base class.
A) multipath
B) multiple
C) multilevel
D) hierarchical

19. The member functions of a derived class can directly access only the ……………….. data.
A) private and protected
B) private and public
C) protected and public
D) private, protected and public

20. The friend functions and the member functions of a friend class can directly access the ………………. data.
A) private and protected
B) private and public
C) protected and public
D) private, protected and public

Answers

1. B) derived, base
2. A) single
3. B) multiple
4. C) multilevel
5. D) hierarchical
6. A) private members
7. C) member functions
8. A) protected
9. C) True, True
10. A) protected
11. C) Public members
12. A) protected
13. A) B(); C(); A();
14. B) C(); B(); A();
15. A) protected
16. C) multilevel
17. B) multiple
18. A) multipath
19. C) protected and public
20. A) private and protected

Read Next: MCQ On Polymorphism Pointer & Virtual Function In C++
Read More: C and C++ MCQ Questions

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.