Signup/Sign In

Test for Polymorphism

This Test will cover Function in Function Overriding, Virtual Functions, Abstract class, Pure Virtual Functions and Virtual Destructors etc.
Q Run time type identification comes at a cost of performance penalty.
Q. Which of the following statement is not correct about function overiding?
Q. What will be the output of following code?
#include <iostream>
using namespace std;

class Base
{
  public:
  void show()
  {
    cout << "Base";
  }
};

class Derived:public Base
{
  public:
  void show()
  {
    cout << "Derived";
   }
};

int main()
{
  Base* b;
  Derived d;
  b = &d;
  b->show();
  return 0;
}
Q. Virtual Keyword is used to make a member function of the _________ class Virtual?

Q. Choose the correct statement?
Q. Which of the following is a correct way to declare Pure Virtual function?
Q What will be the output of following code?
#include <iostream>
using namespace std;

class Base
{
  public:
  ~Base() {cout << "Base Destructor"; }
};

class Derived:public Base
{
  public:
  ~Derived() { cout<< "Derived Destructor"; }
};

int main()
{
  Base* b = new Derived;
  delete b;
  return 0;
}
Q. Pure Virtual Destructors also exist in C++?
Q. The address of the virtual Function is placed in the _________ .

Q. Constructors can also be Virtual. True or False?

Related Tests: