What is the purpose of using static members in a class?
Q.62Medium
Which of the following is an example of compile-time polymorphism?
Q.63Hard
What happens when you try to delete a derived class object through a base class pointer without a virtual destructor?
Q.64Hard
Consider the code: class A { int x; }; class B : private A { }; class C : public B { };
Can class C access x?
Q.65Medium
What is the main difference between composition and inheritance?
Advertisement
Q.66Hard
In C++, what is the result of dynamic_cast when it fails on a pointer?
Q.67Medium
Which of the following correctly uses pure virtual functions?
Q.68Hard
What will be printed by this code?
class A { public: virtual void print() { cout << "A"; } };
class B : public A { public: void print() { cout << "B"; } };
int main() { A *arr[2]; arr[0] = new A(); arr[1] = new B(); arr[0]->print(); arr[1]->print(); }
Q.69Easy
Which C++ feature allows a function to work with objects of different types through a common interface?
Q.70Hard
In a multiple inheritance scenario with diamond problem, how does C++ resolve ambiguity?
Q.71Medium
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.72Medium
Which of the following statements about abstract classes in C++ is true?
Q.73Medium
What is the purpose of the 'const' keyword when used with member functions?
Q.74Medium
In the context of operator overloading, which operator cannot be overloaded in C++?
Q.75Medium
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.76Easy
Which of the following best describes the concept of function overloading?
Q.77Easy
What is the significance of the 'this' pointer in C++?
Q.78Hard
Consider a scenario where class C inherits from both class A and class B, and both A and B have a method foo(). Which statement correctly resolves the ambiguity?
Q.79Hard
What is the relationship between references and pointers in C++ OOP context?
Q.80Medium
Which of the following correctly describes function binding in C++?