Inheritance/Polymorphism  «Prev 

Virtual functions and Abstract Classes

Each question is worth one point. Select the best answer or answers for each question.
 
1. To dynamically select at runtime the appropriate member function from among base and derived class functions, use:
  A. keyword virtual on the base class function
  B. keyword virtual in the class name declaration to specify all functions virtual
  C. keywords pure virtual on all virtual functions in the base class
  D. void* pointer to automatically select among functions

2. In dynamic virtual function selection, the function selected depends on:
  A. the object being pointed at
  B. the pointer type
  C. the return type
  D. none of these

3. ____________ can be virtual.
  A. Any function
  B. Any nonstatic function
  C. Any nonstatic, nonconstructor function
  D. Any nonstatic, nonconstructor, nondestructor function

4. An abstract base class:
  A. consists entirely of pure virtual functions
  B. has no functions, only data members
  C. has at least one pure virtual function
  D. cannot be used in multiple inheritance

5. A pure virtual function:
  A. is declared with = 0; in the base class
  B. has an empty body in the derived class and always uses base class code
  C. has the special null keyword in the body in the base class
  D. cannot appear in an abstract base class

6. An abstract base class:
  A. can be used to declare pointers that can access subtype objects
  B. can be used to declare objects
  C. cannot have any functions containing code
  D. can have only functions that use the virtual keyword

Correct answers:

Your Score: 0