Object Oriented Programming using C++ Questions and Answers – Derived Class

This set of Object Oriented Programming (OOPs) using C++ Multiple Choice Questions & Answers (MCQs) focuses on “Derived Class”.

1. Which among the following is best definition of a derived class?
a) A child class
b) A class which inherits one or more classes
c) A class with keyword derived
d) A class with more than one constructor
View Answer

Answer: b
Explanation: Any class which inherits one or more classes is a derived class. The only condition is it must inherit at least one class in order to be called as a derived class.

2. Which among the following is inherited by a derived class from base class?
a) Data members only
b) Member functions only
c) All the members except private members
d) All the members of base class
View Answer

Answer: c
Explanation: The class inheriting another class, inherits all the data members and member functions that are not private. This is done to ensure the security features with maximum flexibility.

3. If there is a derived class in a program, how many classes must be in that program?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: If there is a derived class in a program, there must be at least 2 classes in that program. One is a base class and another derived class. Hence at least 2 classes must be there.
advertisement
advertisement

4. Which members can never be accessed in derived class from the base class?
a) Private
b) Protected
c) Public
d) All except private
View Answer

Answer: d
Explanation: There is no restriction for a derived class to access the members of the base class until and unless the members are private. Private member are declared so that those members are not accessible outside the class.

5. How many types of inheritance are supported in C++ for deriving a class?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: c
Explanation: There are three types of inheritance possible. Private inheritance, protected inheritance, and public inheritance. The inheritance defines the access specifier to be used with the inherited members in the derived class.

6. How many derived class can a single base class have?
a) 1
b) 2
c) 3
d) As many are required
View Answer

Answer: d
Explanation: There is no restriction on how many classes can inherit a single base class. Hence there can be as many derived classes as required in a program from a single base class.

7. Which among the following is correct?
a) Friend function of derived class can access non-private members of base class
b) Friend function of base class can access derived class members
c) Friend function of derived class can access members of only derived class
d) Friend function can access private members of base class of a derived class
View Answer

Answer: a
Explanation: The friend function of a class can access the non-private members of base class. The reason behind is that the members of base class gets derived into the derived class and hence become members of derived class too. Hence a friend function can access all of those.
advertisement

8. If a class is being derived using more than two base classes, which inheritance will be used?
a) Single
b) Multi-level
c) Hierarchical
d) Multiple
View Answer

Answer: d
Explanation: The statement given is the definition of multiple inheritance with respect to the derived class. The concept can be illustrated with many other samples but the main aspects are base class and derived class only.

9. Derived class is also known as ______________ class.
a) Subclass
b) Small class
c) Big class
d) Noticeable class
View Answer

Answer: a
Explanation: It is just another name given to the derived classes. This is used while denoting all the derived classes subsequent to a superclass.
advertisement

10. If class A is derived from another derived class B which is derived from class C, which class will have maximum level of abstraction?
a) Class A
b) Class B
c) Class C
d) All have the same level of abstraction
View Answer

Answer: c
Explanation: The abstraction level of class C will be maximum. This is because the parent class have higher level of abstraction. Hence the parent of all other class will have maximum level of abstraction.

11. If base class is an abstract class then derived class ______________ the undefined functions.
a) Must define
b) Must become another abstract class or define
c) Must become parent class for
d) Must implement 2 definitions of
View Answer

Answer: b
Explanation: The function must be defined in the program which are not defined in the base class. Hence the class must be defined as abstract of implement the function definition in it.

12. How many classes can be derived from a derived class?
a) Only 1
b) At most 1
c) At least 1
d) As many as required
View Answer

Answer: d
Explanation: When a class is to be derived from another derived class, the derived class behaves as a normal base class hence there are no restriction on how many class can be derived from a derived class. The derived class again behaves as a normal superclass.

13. The members of a derived class can never be derived.
a) True
b) False
View Answer

Answer: b
Explanation: This is not true that the members of a derived class can’t be derived. All the classes are considered to be a normal class when used for derivation. The members can be derived with respect to their access specifiers.

14. Which feature is not related to the derived classes among the following?
a) Inheritance
b) Encapsulation
c) Run time memory management
d) Compile time function references
View Answer

Answer: c
Explanation: The memory management is the feature that is not necessary for derived classes that will be a part of whole program. The functions references must be resolved for their proper use if inheritance is used.

15. Deriving a class in such a way that that the base class members are not available for further inheritance is known as ___________________
a) Public inheritance
b) Protected inheritance
c) Protected or private inheritance
d) Private inheritance
View Answer

Answer: d
Explanation: The private members of a class can never be derived to another class. When a class derives another class using private inheritance, all the members become private members of the derived class. Hence these member won’t be available for further inheritance.

Sanfoundry Global Education & Learning Series – Object Oriented Programming (OOPs).

To practice all areas of Object Oriented Programming (OOPs) using C++, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.