This set of Object Oriented Programming (OOPs) 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
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.
2. A base class is also known as _____________ class.
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.
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.
4. How many base classes can a single class inherit in java?
d) As many as required
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
Explanation: Making another class derive from it will make that class as base class. It is not necessary that we have to write a different code for it. If at least one class derives that class, it becomes the base class for the new class.
6. If a base class is being derived by two other classes, which inheritance will that be called?
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
Explanation: Even a class which doesn’t have any members can be a base class. It is not mandatory to have any member or attribute in base class.
8. Which type of members can’t be accessed in derived classes of a base class?
d) All can be accessed
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.
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.
10. Base class have ________________ of abstraction.
a) Higher degree
b) Lower degree
d) Minimum degree
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.
d) According to priority of
Explanation: When the base class object is created, its constructor will be called for sure. But if 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 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
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?
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++?
d) As many as required
Explanation: This is because C++ allows the 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 few new members, its subclass must also be modified. (True/False)
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), here is complete set of 1000+ Multiple Choice Questions and Answers.