Q) Features not available in C++ object oriented programming is
  1. Virtual destructor
  2. Virtual constructor
  3. Virtual function
  4. All

Answer: 2

There is no concept of virtual constructor available in C++. However, virtual destructor is available in C++ language to maintain the destructor call from derived to base class. In polymorphic classes, if we don’t use virtual destructor in base class then the derived class destructor will not be called that may cause resource leaks.

Recommended to read why there is no virtual constructor in C++ language and a complete details of virtual destructor with example. It’s uses and how and when resources can leak etc.


Q) IS A relationship in C++ is
  1. Inheritance
  2. Encapsulation
  3. Composition
  4. None

Answer: 1


Q) If you want to write multiple functions in a class with same name, then what C++ feature will you use?
  1. Function overriding
  2. Encapsulation
  3. Function overloading
  4. None

Answer: 3

Compile time polymorphism feature is used i.e. function overloading in C++. Function overloading means, in a class, multiple functions with same name can be written with different signatures, return types etc.



Q) Polymorphism types is/are
  1. Compile time
  2. Run time
  3. Both
  4. None

Answer: 3

Two types of Polymorphism are available in C++ object oriented programming i.e. compile time and run time polymorphism. Also, known as early binding and late binding respectively.

Compiler time polymorphism features in C++ language are function overloading, constructor and operator overloading etc. and run time polymorphism is function overriding in inheritance relationship.


Q) If I want to have common functions in a class and want to defer implementations of some other functions to derived classes, then we need to use
  1. An interface
  2. An abstract class
  3. A friend class
  4. A static class

Answer: 2

In C++ object oriented programming, abstract class is used for the same, in which we have common or say generalized function in abstract base class and also may have pure virtual function in this class that forces derived classes to implement it.

Read in detail about an abstract class oops concept with example in C++ and also, pure virtual function used to create an abstract class and interface in C++ language.


Related Posts