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

«
»

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

1. Which is most appropriate definition of a base class?
a) It is parent of any of its derived class
b) It is child of one of the parent class
c) It is most basic class of whole program
d) It is class with maximum number of members
View Answer

Answer: a
Explanation: A class which is parent of another class, or from which other classes can be derived, is known as a base class. It is mandatory that a class must have at least one derived class to be called as a base class.
advertisement

2. A base class is also known as _____________ class.
a) Basic
b) Inherited
c) Super
d) Sub
View Answer

Answer: c
Explanation: A class which is being derived by other classes, is called as super class. This concept is clearly used in java as we call the functions of a base class by using the keyword super as required.

3. An abstract class is always a __________ class.
a) Base
b) Derived
c) Template
d) Nested
View Answer

Answer: a
Explanation: Every abstract class is a base class. It must be so, because the functions which are not defined inside the abstract class, must be defined in the derived classes. Hence it becomes a base class.
advertisement
advertisement

4. How many base classes can a single class inherit in java?
a) 1
b) 2
c) 3
d) As many as required
View Answer

Answer: a
Explanation: In java, multiple inheritance is not supported, which leads to the fact that a class can have only 1 parent class if inheritance is used. Only if interfaces are used then the class can implement more than one base class.

5. How to make a derived class a base class?
a) Change name of the class
b) Use keyword base
c) Make a class derive from it
d) Can’t be done
View Answer

Answer: c
Explanation: Making another class derive from it will make that class as base class. It is not necessary that we have to write different code for it. If at least one class derives that class, it becomes the base class for the new class.
advertisement

6. If a base class is being derived by two other classes, which inheritance will that be called?
a) Single
b) Multiple
c) Multi-level
d) Hierarchical
View Answer

Answer: d
Explanation: When more than one classes are being derived from a single parent class, the inheritance is known as hierarchical inheritance. This is usually useful when the base class is higher abstraction of its derived classes.

7. Which among the following must be in a base class?
a) Data members
b) Member functions
c) Access specifiers
d) Nothing
View Answer

Answer: d
Explanation: Even a class that doesn’t have any members can be a base class. It is not mandatory to have any member or attribute in base class.
advertisement

8. Which type of members can’t be accessed in derived classes of a base class?
a) Protected
b) Private
c) Public
d) All can be accessed
View Answer

Answer: b
Explanation: The private members can be accessed only inside the base class. If the class is derived by other classes. Those members will not be accessible. This concept of OOP is made to make the members more secure.

9. If a class is enclosing more than one class, than it can be called as base class of those classes.
a) True
b) False
View Answer

Answer: b
Explanation: When a class have more than one nested classes, it is known as enclosing class. It can’t be called as parent or base class since there is no inheritance involved.
advertisement

10. Base class have ________________ of abstraction.
a) Higher degree
b) Lower degree
c) Intermediate
d) Minimum degree
View Answer

Answer: b
Explanation: A base class will have lesser information as compared to those of derived classes. Since derived classes inherit the base class properties and then add on their own features, they elaborate more hence have lower degree of abstraction.

11. Always the base class constructors are called ___________ constructor of derived class.
a) Before
b) After
c) Along
d) According to priority of
View Answer

Answer: a
Explanation: When the base class object is created, its constructor will be called for sure. But if a derived class constructor is called, first base class constructor is called and then derived class constructor is taken into consideration.

12. Can we call methods of base class using the constructor of the derived class?
a) Yes, always
b) Yes, but not always
c) No, never
d) No, but we can call in some cases
View Answer

Answer: a
Explanation: If the function is defined in the base class, it can always be called from the constructor of its derived class. Since the constructors are not private, they can be accessed in derived class even if those are protected.

13. If a base class is inherited from another class and then one class derives it, which inheritance is shown?
a) Multiple
b) Single
c) Hierarchical
d) Multi-level
View Answer

Answer: d
Explanation: If a base class is inherited from another class, single inheritance is shown. But when one more class inherits the derived class, this becomes a multi-level inheritance.

14. How many base classes can a single derived class have in C++?
a) 1
b) 2
c) 3
d) As many as required
View Answer

Answer: d
Explanation: This is because C++ allows multiple inheritance. A derived class can have more than one base class and hence can derive all of their features.

15. If a base class is added with a few new members, its subclass must also be modified.
a) True
b) False
View Answer

Answer: b
Explanation: The base class can be added with new members without affecting the subclasses. This is because the subclasses may get some more features inherited but it won’t use them. But the base class will be able to use the new members as would be required.

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.

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!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter