Which of the following correctly demonstrates constructor overloading?
Q.2Medium
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 *b = new Derived();
b->display();
}
Q.3Medium
What is the difference between method overloading and method overriding?
Q.4Medium
Which of the following is true about abstract classes in C++?
Q.5Medium
Which type of inheritance can lead to the Diamond Problem in C++?
Advertisement
Q.6Medium
What is a copy constructor in C++?
Q.7Medium
Which of the following demonstrates proper encapsulation?
Q.8Medium
Which of the following is a characteristic of a pure virtual function?
Q.9Medium
What is the main advantage of using interfaces/abstract classes in C++?
Q.10Medium
What is 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.11Medium
Which of the following statements about abstract classes in C++ is correct?
Q.12Medium
What will be the output of the following code?
class A {
public:
A() { cout << "A "; }
};
class B : public A {
public:
B() { cout << "B "; }
};
int main() {
B obj;
}
Q.13Medium
What is the main difference between method overloading and method overriding?
Q.14Medium
What does encapsulation in C++ primarily achieve?
Q.15Medium
What is the purpose of the 'const' keyword when applied to member functions?
Q.16Medium
What happens when you try to call a non-virtual function through a pointer to a base class pointing to a derived object?
Q.17Medium
Which keyword is used to prevent a derived class from further overriding a virtual function in C++?
Q.18Medium
What is the output of the following code?
class Base { public: void display() { cout << "Base"; } };
class Derived : public Base { public: void display() { cout << "Derived"; } };
Base obj = Derived();
obj.display();
Q.19Medium
Consider a scenario where Class B inherits from Class A, and Class C also inherits from Class A. Class D inherits from both B and C. Which problem does this create?