C++ 1. In order to use a dynamic_cast<> in a C++ program, runtime type informati
ID: 3716057 • Letter: C
Question
C++
1. In order to use a dynamic_cast<> in a C++ program, runtime type information must be enabled.
a. true
b. false
2. In C++, a call to a virtual method though a base class pointer to a derived class object will use
a. dynamic binding / dynamic linkage.
b. automatic binding / static linkage.
c. static binding / static linkage.
d. external binding / external linkage.
3. With public inheritance, the protected members of a base class can be accessed by
a. methods of that base class.
b. friends of that base class.
c. methods of any classes derived from that base class.
d. All of the above.
4. What is the C++ syntax for declaring the class Dog to be a derived class of the base class Pet?
a. class Pet : public Dog
b. class Dog : public Pet
c. class Dog public subclass of Pet
d. class Dog derived from public Pet
5. When a derived class object is destroyed, in what order are the destructors executed?
a. First the derived class destructor is executed, then the base class destructor is executed.
b. First the base class destructor is executed, then the derived lass destructor is executed.
c. Only the base class destructor is executed.
d. Only the derived class destructor is executed.
Explanation / Answer
1. For both dynamic_cast and typeid, the compiler must enable Run-Time Type Information (RTTI).
a) True
2. In C++, a call to a virtual method though a base class pointer to a derived class object will use
a) dynamic binding / dynamic linkage.
3. With public inheritance, the protected members of a base class can be accessed by
d) All of the above.
4. C++ syntax for declaring the class Dog to be a derived class of the base class Pet is
b) class Dog : public Pet.
5. The destructors are executed in the following way :
Derived class, then members of derived class, then the base class, and lastly the members of the base class.
So, the correct answer will be
a) First the derived class destructor is executed, then the base class destructor is executed.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.