iGET

C++ Programming - MCQ Practice Questions

C++ MCQs — OOP, STL, pointers, templates for coding rounds & IT exams.

100 questions | 100% Free

Q.21Medium

Which of the following is NOT a type of polymorphism in C++?

Q.22Medium

What will be the output of the following code? class A { public: virtual void func() { cout << "A"; } }; class B : public A { public: void func() { cout << "B"; } }; A *ptr = new B(); ptr->func(); delete ptr;

Q.23Medium

In C++, what is a friend function?

Q.24Medium

In C++11 and later, what does the 'override' keyword ensure when used with virtual functions?

Q.25Medium

Which of the following statements about constructors in C++ is FALSE?

Q.26Medium

In C++, what is the default access specifier for class members?

Q.27Medium

What is the output of the following code? class Base { public: void show() { cout << "Base"; } }; class Derived : public Base { public: void show() { cout << "Derived"; } }; int main() { Base *b = new Derived(); b->show(); }

Q.28Medium

Which statement about 'this' pointer is correct?

Q.29Medium

What is the purpose of using static members in a class?

Q.30Medium

Which of the following is an example of compile-time polymorphism?

Q.31Medium

What is the main difference between composition and inheritance?

Q.32Medium

Which of the following correctly uses pure virtual functions?

Q.33Medium

What will be the output of the following code? class Base { public: virtual void display() { cout << "Base"; } }; class Derived : public Base { public: void display() { cout << "Derived"; } }; int main() { Base *ptr = new Derived(); ptr->display(); }

Q.34Medium

Which of the following statements about abstract classes in C++ is true?

Q.35Medium

What is the purpose of the 'const' keyword when used with member functions?

Q.36Medium

In the context of operator overloading, which operator cannot be overloaded in C++?

Q.37Medium

What is the output of the following code? class A { public: int x = 5; }; class B : public A { public: int x = 10; }; int main() { B obj; cout << obj.x; }

Q.38Medium

Which of the following correctly describes function binding in C++?

Q.39Medium

What will be printed by the following code? class Test { int x; public: Test() { x = 0; } ~Test() { cout << "Destructor"; } }; int main() { Test t1, t2; return 0; }

Q.40Medium

What is the primary advantage of using virtual functions in a base class?