Q) Not using virtual destructor feature in a C++ object oriented programing can cause
  1. Memory leak
  2. An Issue in creating object of the class
  3. An issue in calling base class destructor
  4. Nothing

Answer: 1

Virtual destructor is used to maintain the hierarchy of destructor calls for polymorphic classes in inheritance. If we don’t use it then it may cause resource leak or memory leak.


Q) Which C++ oops feature is related to re-usability?
  1. Encapsulation
  2. Inheritance
  3. Abstraction
  4. None

Answer: 2
Inheritance feature is used for concept of code re-usability as in inheritance a class can inherit properties and functions of existing well written class.
Abstraction : Provide only necessary information to client code.
Encapsulation: Hide complexity. e.g. by wrapping private class data members by functions. By making internal function of a class private and using interfaces etc.


Related Posts