Explore topic-wise MCQs in C++ Programming.

This section includes 9 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

What is a pure virtual function?

A. A virtual function defined inside the base class
B. A virtual function that has no definition relative to the base class
C. A virtual function that is defined inside the derived class
D. Any function that is made virtual
Answer» C. A virtual function that is defined inside the derived class
2.

The concept of deciding which function to invoke during runtime is called ______________________

A. late binding
B. dynamic linkage
C. static binding
D. both late binding and dynamic linkage
Answer» E.
3.

Which statement is incorrect about virtual function.

A. They are used to achieve runtime polymorphism
B. They are used to hide objects
C. Each virtual function declaration starts with the virtual keyword
D. All of the mentioned
Answer» C. Each virtual function declaration starts with the virtual keyword
4.

Which is the correct syntax of declaring a virtual function?

A. virtual int func();
B. virtual int func(){};
C. inline virtual func();
D. inline virtual func(){};
Answer» B. virtual int func(){};
5.

What is a virtual function in C++?

A. Any member function of a class
B. All functions that are derived from the base class
C. All the members that are accessing base class data members
D. All the functions which are declared in the base class and is re-defined/overridden by the derived class
Answer» E.
6.

If a class is derived privately from a base class then ______________________________

A. no members of the base class is inherited
B. all members are accessible by the derived class
C. all the members are inherited by the class but are hidden and cannot be accessible
D. no derivation of the class gives an error
Answer» D. no derivation of the class gives an error
7.

Which specifier makes all the data members and functions of base class inaccessible by the derived class?

A. private
B. protected
C. public
D. both private and protected
Answer» B. protected
8.

How many specifiers are used to derive a class?

A. 1
B. 2
C. 3
D. 4
Answer» D. 4
9.

What is Inheritance in C++?

A. Wrapping of data into a single class
B. Deriving new classes from existing classes
C. Overloading of classes
D. Classes with same names
Answer» C. Overloading of classes