Question 1
Question 2
#include
using namespace std;
class Base
{
public:
virtual void show() { cout<<" In Base \\n"; }
};
class Derived: public Base
{
public:
void show() { cout<<"In Derived \\n"; }
};
int main(void)
{
Base *bp, b;
Derived d;
bp = &d;
bp->show();
bp = &b;
bp->show();
return 0;
}
In Base In Base
In Base In Derived
In Derived In Derived
In Derived In Base
Question 3
In C++ inheritance, which constructor is called first when an object of a derived class is created?
Derived class constructor
Base class constructor
Constructors are called randomly
t depends on access specifier
Question 4
#include
using namespace std;
class Base {
public:
virtual ~Base() {}
};
int main() {
return 0;
}
Question 5
Which of the following statements are true regarding C++?
(a) Overloading gives the capability to an existing operator to operate on other data types.
(b) Inheritance in object oriented programming provides support to reusability.
(c) When object of a derived class is defined, first the constructor of derived class is executed then constructor of a base class is executed.
(d) Overloading is a type of polymorphism.
Choose the correct option from those given below:
(a) and (b) only    Â
(a), (b) and (c) only
(a), (b) and (d) only    Â
(b), (c) and (d) only
Question 6
What is polymorphism in OOP?
The ability of a class to inherit from multiple classes
The ability to redefine methods in derived classes
The ability to use the same interface for different data types
The ability to hide the implementation details of a class
Question 7
How run-time polymorphisms are implemented in C++?
Using Inheritance
Using Friend functions
Using Templates
Using Virtual Functions
Question 8
Which of the following is a static polymorphism mechanism?
Function overloading
Operator overloading
Templates
All of the mentioned
There are 8 questions to complete.