QUIZ III SET 1 Solution
QUIZ III SET 1 Solution
1. Which of the following is valid when accessing a base class function from a derived class?
a) baseFunc(); b) Base::baseFunc();
c) this->baseFunc(); d) All of the above
12. A class Shape is inherited by both 2DShape and 3DShape, and 2DShape is further inherited by Rectangle.
This represents _______________ inheritance.
Answer: hybrid
13. A _______________ function in a base class ensures that the derived class's function is executed at runtime
through a base class pointer.
Answer: virtual
14. Which type of inheritance is necessary for achieving polymorphism in C++.
a) Single b) Multiple
c) Multilevel d) Heirarchical
15. If same message is passed to objects of several different classes and all of those can respond in a different
way, what is this feature called?
a) Inheritance b) Overloading
c) Polymorphism d) Overriding
17. Which concept will result in derived class with more features (consider maximum 3 classes)?
a) Single inheritance
b) Multiple inheritance
c) Multilevel inheritance
d) Hierarchical inheritance
18. If a base class pointer is used to store the address of a derived class object and a non-virtual function is
called through this pointer, the base class function will be invoked, irrespective of the derived class's
definition.
a) True b) False
Answer: True
19. In C++, an abstract class can be instantiated if it has at least one virtual function defined in its base
class.
a) True b) False
Answer: False (An abstract class cannot be instantiated regardless of its functions' definitions.)
20. The visibility mode of inheritance impacts whether a derived class can override the private members of
its base class.
a) True b) False
Answer: False (Private members cannot be accessed or overridden by derived classes, regardless of
visibility mode.)