Search Header Logo

MCQs on Polymorphism in C++

Authored by stuti Ahuja

Computers

University

Used 1+ times

MCQs on Polymorphism in C++
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is an example of compile-time polymorphism?

Function Overloading

Operator Overloading

Both A and B

None of the above

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? class Base { public: virtual void display() { cout << "Base Display"; } }; class Derived : public Base { public: void display() { cout << "Derived Display"; } }; Base* b = new Derived(); b->display();

Base Display

Derived Display

Compilation Error

Runtime Error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements about virtual functions is true?

They can be static.

They cannot be overridden.

They must be defined in the base class.

They are always inlined.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens if a derived class does not override a virtual function?

The derived class will have a compilation error.

The base class function will be called.

The derived class will call its own function.

None of the above.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you declare a pure virtual function in C++?

virtual void func() = 0;

void func() = 0;

void func();

virtual void func();

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct way to implement polymorphism?

Using function overloading.

Using operator overloading.

Using virtual functions.

All of the above.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following best describes dynamic polymorphism?

It occurs at compile-time.

It is achieved through virtual functions and inheritance.

It is the same as function overloading.

None of the above.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?