ProgrammingVery hardProduct-company placement · C++

How many of these statements about C++ are correct? (i) A constructor cannot be declared virtual. (ii) A static member function cannot be virtual. (iii) A virtual function declared private in the base class can still be overridden in a derived class. (iv) A destructor cannot be declared pure virtual.

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 1

Correct answer: B. 3

(i), (ii) and (iii) are correct (access control does not affect overriding; this is the NVI idiom). (iv) is false: a pure virtual destructor is allowed and makes the class abstract, but it must still be given a definition.

More OOP with C++ and Java questions

Exams that ask this topic