GkSeries.com

Inheritence - C++ Multiple Choice Questions(MCQs)& Answers

(21) A member declared as ………….. is accessible by the member functions within its class and any class immediately derived from it.
[A] protected
[B] privates
[C] public
[D] friend
Answer: Option [A]
(22) When the base class is publicly inherited, public members of the base class become …………. of the derived class.
[A] private members
[B] protected members
[C] Public members
[D] Not inherite
Answer: Option [C]
(23) In protected derivation, both the public and protected members of the base class become …………. members of the derived class.
[A] protected
[B] private
[C] public
[D] friend
Answer: Option [A]
(24) What will be the order of execution of base class constructors in the following method of inheritance.

class A: public B, public C {….};

What will be the order of execution of base class constructors in the following method of inheritance.

class A: public B, virtual public C {….};

[A] B(); C(); A();
[B] C(); B(); A();
[C] A(); B(); C();
[D] B(); A(); C();
Answer: Option [A]
(25) What will be the order of execution of base class constructors in the following method of inheritance. class A: public B, virtual public C {….};
[A] B(); C(); A();
[B] C(); B(); A();
[C] A(); B(); C();
[D] B(); A(); C();
Answer: Option [B]
(26) While the friend functions and the member functions of a friend class can have direct access to both the private and protected data, the member functions of a derived class can directly access only the ………… data.
[A] protectedd
[B] derived, base
[C] public
[D] friend
Answer: Option [A]
(27) In ……………………. inheritance, the constructors are executed in the order of inheritance.
[A] multipath
[B] multiple
[C] multilevel
[D] hierarchical
Answer: Option [C]
(28) In ……………….. inheritance, the base classes are constructed in the order in which they appear in the deceleration of the derived class.
[A] multipath
[B] multiple
[C] private
[D] multilevel
Answer: Option [B]
(29) ……………….. inheritance may lead to duplication of inherited members from a ‘grandparent’ base class.
[A] multipath
[B] multiple
[C] multilevel
[D] hierarchical
Answer: Option [A]
(30) The member functions of a derived class can directly access only the ……………….. data.
[A] private and protected
[B] private and public
[C] protected and public
[D] private, protected and public
Answer: Option [C]
31 The friend functions and the member functions of a friend class can directly access the ………………. data.
[A] private and protected
[B] private and public
[C] protected and public
[D] private, protected and public
Answer: Option [A]
32 In compile time polymorphism, compiler is able to select the appropriate function for a particular call at the compile time itself, which is known as …………
[A] early binding
[B] static binding
[C] static linking
[D] All of the above
Answer: Option [B]
33 . ……………. binding means that, an object is bound to its function call at compile time.
[A] late
[B] static
[C] dynamic
[D] fixed
Answer: Option [B]
34 C++ supports run time polymorphism with the help of virtual functions, which is called …………….. binding.
[A] dynamic
[B] run time
[C] early binding
[D] static
Answer: Option [A]
35 State whether the following statements about pointers in C++ are True. i) A pointer can be incremented (++) or decremented (–) ii) Any integer can be added to or subtracted from a pointer iii) One pointer can be subtracted from another)
[A] i and ii only
[B] ii and iii only
[C] i and iii only
[D] All i, ii and iii
Answer: Option [D]
36 . ………………. are also known as generic pointers, which refer to variables of any type.
[A] void pointers
[B] null pointers
[C] this pointer
[D] base pointer
Answer: Option [A]
37 The pointers which are not initialized in a program are called ……………..
[A] void pointers
[B] null pointers
[C] this pointer
[D] base pointer
Answer: Option [B]
38 …………………… is useful in creating objects at run time.
[A] void pointer
[B] null pointer
[C] this pointer
[D] object pointerd
Answer: Option [D]
39 A …………………. refers to an object that that currently invokes a member function.
[A] void pointers
[B] null pointers
[C] this pointer
[D] base pointer
Answer: Option [C]
40 The …………………. cannot be directly used to access all the members of the derived class.
[A] void pointers
[B] null pointers
[C] this pointer
[D] base pointern
Answer: Option [D]