Test Series - cpp

Test Number 58/102

Q: What is meant by multiple inheritance?
A. Deriving a base class from derived class
B. Deriving a derived class from base class
C. Deriving a derived class from more than one base class
D. Deriving a derived base class
Solution: Multiple inheritance enables a derived class to inherit members from more than one parent.
Q: Which symbol is used to create multiple inheritances?
A. Dot
B. Comma
C. Dollar
D. star
Solution: For using multiple inheritance, simply specify each base class (just like in single inheritance), separated by a comma.
Q: Which of the following advantages we lose by using multiple inheritances?
A. Dynamic binding
B. Polymorphism
C. Both Dynamic binding & Polymorphism
D. Constructor
Solution: The benefit of dynamic binding and polymorphism is that they help making the code easier to extend but by multiple inheritance it makes harder to track.
Q: Which design patterns benefit from the multiple inheritances?
A. Adapter and observer pattern
B. Code pattern
C. Glue pattern
D. Star pattern
Solution: Adapter and observer patterns benefit from the multiple inheritances.
Q: What are the things are inherited from the base class?
A. Constructor and its destructor
B. Operator=() members
C. Friends
D. All of the mentioned
Solution: These things can provide necessary information for the base class to make a logical decision.
Q: What is Inheritance in C++?
A. Wrapping of data into a single class
B. Deriving new classes from existing classes
C. Overloading of classes
D. Classes with same names
Solution: Inheritance is the concept of OOPs in which new classes are derived from existing classes in order to reuse the properties of classes defined earlier.
Q: How many specifiers are used to derive a class?
A. 1
B. 2
C. 3
D. 4
Solution: There are 3 specifiers used to derive a class. They are private, protected and public.
Q: Which specifier makes all the data members and functions of base class inaccessible by the derived class?
A. private
B. protected
C. public
D. both private and protected
Solution: Private access specifier is used to make all the data members and functions of the base class inaccessible.
Q: If a class is derived privately from a base class then ______________________________
A. no members of the base class is inherited
B. all members are accessible by the derived class
C. all the members are inherited by the class but are hidden and cannot be accessible
D. no derivation of the class gives an error
Solution: Whenever a class is derived, all the members of the base class is inherited by the derived class but are not accessible by the derived class.
Q: What is a pure virtual function?
A. A virtual function defined inside the base class
B. A virtual function that has no definition relative to the base class
C. A virtual function that is defined inside the derived class
D. Any function that is made virtual
Solution: A virtual function that has no definition relative to the base class is called a pure virtual function.

You Have Score    /10