Virtual Function MCQs – C++
1. A virtual function is a member function of which of the following class?
(A). Derived class
(B). Parent class
(c). base class
(D). Both A and B
2. A virtual function is redefined in which of the following class?
(A). Derived class
(B). Parent class
(c). base class
(D). Both A and B
3. The virtual function is used to tell the compiler to perform ________?
(A). static linkage
(B). dynamic linkage
(c). late binding
(D). Both B and C
4. Which of the following best describes the virtual function?
(A). Function overriding
(B). write a function in the child class that is already present in the parent class
(c). Run time polymorphism
(D). All of these
5. In late binding, function call is resolved during?
(A). runtime
(B). Compile time
(c). Infinite time
(D). None of these
6. Late binding can be implemented by which of the following?
(A). Function overloading
(B). Function overriding
(c). Virtual function
(D). B and C
7. Early binding can be implemented by which of the following?
(A). Virtual function
(B). Function overriding
(C). Function overloading
(D). B and C
8. Which statement is true about virtual functions?
(A). Virtual functions can be static members
(B). Virtual functions cannot be static members
(c). Virtual functions must be members of some class
(D). B and C
9. Compiler can access the Virtual Functions with the help of_____ pointers?
(A). Class
(B). object
(c). Assigning address of child class object to parent class object and parent having a virtual function
(D). B and C
10. The signatures of a virtual function of the base class and all the derived classes are ____ ?
(A). Different
(B). same
(c). Sometimes same, sometimes different
(D). None of these
What is an example of function overloading?
(A). Two functions with different signatures
(B). Two functions with the same signatures
(c). Two functions with no signatures
(D). None of these
11. A program can have?
(A). Virtual Constructor
(B). Virtual Destructor
(c). Both of these
(D). None of these
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include<iostream> using namespace std; class Parent { public: Parent() { cout<<"Constructor is started for parent class \n"; } virtual ~Parent() { cout<<"Destructor is started for parent class \n"; } }; class child: public Parent { public: child() { cout<<"Constructor is started for child class \n"; } ~child() { cout<<"Destructor is started for Child class \n"; } }; int main(void) { child *t4tutorials = new child(); Parent *dotcom = t4tutorials; delete dotcom; return 0; } |
Full Tutorial: Virtual Function in C++
Virtual Class MCQs – C++
OOP MCQs
- OOP intro & examples MCQs
- Classes and Inheritance MCQs
- Friend Function MCQs
- Virtual Function MCQs
- Polymorphism MCQs
- Polymorphism MCQs 2
- Operator overloading MCQs
- Object Oriented Programming MCQs – Very Important
Programming C Plus Plus MCQs Homepage
- Low-level and high-level languages MCQs
- Procedural and non Procedural languages MCQs
- C++ STANDARD LIBRARY MCQs
- Array MCQs
- Arrays MCQs 2
- Pointers Solved MCQs
- Inline Function MCQs – C++
- Top 50 Programming C++ MCQs
- MCQs of introduction to programming
- Past Papers 2022 C++ MCQs
- Past Papers 2021 C++ MCQs
- Past Papers 2020 C++ MCQs
- Past Papers 2019 C++ MCQs
- Highly Recommended C++ Important MCQs with Explanation
- OOP
- OOP intro & examples MCQs
- Classes and Inheritance MCQs
- Friend Function MCQs
- Virtual Function MCQs
- Polymorphism MCQs
- Polymorphism MCQs 2