Object Oriented Programming 2072
Section A
Attempt any two questions: (2x10=20)
1. Explain the object oriented programming with its advantages. What are the features of object oriented languages? Explain.
2. Write a program to overload the unary minus operator using friend function.
3. Explain the role of inheritance in object oriented programming. What is public, private and protected dentation? Explain.
Section B
Attempt any eight questions: (8x5 = 40)
4. Explain the syntax and rules of multiple inheritance in C++ with example.
When a class is derived from two or more base classes, such inheritance is called Multiple Inheritance. Multiple Inheritance in C++ allow us to combine the features of several existing classes into a single class.
Syntax:
class base_class1
{
// body of the class
};
class base_class2
{
//body of the class
};
class derived_classname : visibility_mode base_class1, visibility_mode base_class2
{
//body of the class
};
Example:
#include <iostream>
using namespace std;
class A
{
protected:
int a;
public:
void get_a(int n)
{
a = n;
}
};
class B
{
protected:
int b;
public:
void get_b(int n)
{
b = n;
}
};
class C : public A, public B
{
public:
void display()
{
cout << "The value of a is : " <<a<<endl;
cout << "The value of b is : " <<b<<endl;
cout <<"Addition of a and b is : "<<a+b;
}
};
int main()
{
C obj;
obj.get_a(10);
obj.get_b(20);
obj.display();
return 0;
}
5. Explain do/while structure with example.
6. Explain the Inline function with example.
7. What is multiple inheritance? Explain with example.
8. Explain the static class members with example.
9. Differentiate between macro and function.
10. Explain the use of break and continue statements in switch case statements in C++.
11. Explain the different storage classes in C++.
12. Explain the multilevel inheritance. How is it different from multiple inheritance?
13. Explain the exceptional handling with example.