Test Series - oops

Test Number 35/78

Q: 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
Solution: 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.
Q: 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
Solution: 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.
Q: Which members can never be accessed in derived class from the base class?
A. Private
B. Protected
C. Public
D. All except private
Solution: 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.
Q: 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
Solution: 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.
Q: 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
Solution: 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.
Q: Derived class is also known as ______________ class.
A. Subclass
B. Small class
C. Big class
D. Noticeable class
Solution: It is just another name given to the derived classes. This is used while denoting all the derived classes subsequent to a superclass.
Q: 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
Solution: 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.
Q: 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
Solution: 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.
Q: 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
Solution: 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.
Q: 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
Solution: 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.

You Have Score    /10