0% found this document useful (0 votes)
15 views

Tutorial-8_polymorphism

The document is a tutorial for a B. Tech. course on Object Oriented Programming, focusing on polymorphism in C++. It includes questions about the definition of polymorphism, abstract classes, pure virtual functions, and provides code examples to analyze outputs. The tutorial aims to enhance understanding of class inheritance and destructor behavior in C++.

Uploaded by

om gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Tutorial-8_polymorphism

The document is a tutorial for a B. Tech. course on Object Oriented Programming, focusing on polymorphism in C++. It includes questions about the definition of polymorphism, abstract classes, pure virtual functions, and provides code examples to analyze outputs. The tutorial aims to enhance understanding of class inheritance and destructor behavior in C++.

Uploaded by

om gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Jaypee University of Engineering and Technology

B. Tech. (CSE) - II Semester


Object Oriented Programming (CS102)
Tutorial – 8(Polymorphism)

Q1 What is Polymorphism in C++? How many types of polymorphism? Explain with the help of
suitable example.

Q2 Define abstract class and pure virtual function.

Q3What is output of the following program?

class student
{
public: int marks;
void disp()
{
cout<<”its base class”;
}
};
class topper: public student
{
public: void disp()
{
cout<<”Its derived class”;
}
};
int main()
{
student s;
topper t;
s.disp();
t.disp();
}

Q4 Find the output of the following program.

class education
{
char name[10];
public:
void disp()
{
cout<<”Its education system”;
}
};
class school: public education
{
public:
void disp()
{
cout<<”Its school education system”;
}
};
int main()
{
school s;
s.disp();
}

Q5 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;
}

You might also like