C++ Programming - MCQ Practice Questions
C++ MCQs — OOP, STL, pointers, templates for coding rounds & IT exams.
100 questions | 100% Free
Which of the following is an example of operator overloading as a member function?
In which scenario would you use an abstract base class instead of a concrete base class?
What will be 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(); }
Consider a scenario where a derived class needs to access a base class member that should not be accessible to external code. Which access specifier should be used in the base class?
What is the output of the following code? class A { public: virtual void func() { cout << "A"; } }; class B : public A { public: void func() { cout << "B"; } }; class C : public B { public: void func() { cout << "C"; } }; int main() { A *p = new C(); p->func(); }
Which of the following statements about constructors is correct?
What is the primary use of the 'const' keyword when applied to member functions?
Which of the following best describes the concept of method overloading?
In C++, when a derived class overrides a virtual function from a base class, which access specifier must be used to ensure proper polymorphic behavior?