Object Oriented Programming 2080
Section A
Long Answer Questions
Attempt any TWO questions. [2 × 10 = 20]
AI is thinking...
1. What is a constructor? Explain its types with a suitable example. How is the constructor called in a derived class in C++? [2+6+2]
AI is thinking...
2. What is polymorphism in Object Oriented Programming? Implement a class Employee
with a virtual function CalculateSalary()
that returns the salary of the employee. Create two derived classes HourlyEmployee
and SalariedEmployee
. Override the CalculateSalary()
function in both derived classes to calculate the salary of an hourly employee and a salaried employee, respectively. Write a program that creates objects of both derived classes and calls the CalculateSalary()
function for each. [2+8]
AI is thinking...
3. What is operator overloading? Write a complete C++ program to overload the +
operator to add two objects of class Time
. [3+7]
AI is thinking...
Section B
Short Answer Questions
Attempt any EIGHT questions. [8 × 5 = 40]
AI is thinking...
4. What is the difference between public, private, and protected inheritance in C++? [5]
AI is thinking...
5. What is exception handling? Explain types of exception handling and provide a suitable example. [1+4]
AI is thinking...
6. What is a friend function? Write a program to add private members of two different classes using a friend function. [1+4]
AI is thinking...
7. Write a program to demonstrate returning an object from functions in C++. [5]
AI is thinking...
8. How is the this
pointer used to resolve name conflicts between local variables and member variables in C++? Explain with an example. [5]
AI is thinking...
9. Write a program to read and write values through an object using file handling. [5]
AI is thinking...
10. What do you mean by a class template in C++? Write a program in C++ containing a function template that determines the greater number between two integer inputs and two floating-point inputs. [5]
AI is thinking...
11. Differentiate between function overloading and function overriding in C++. [5]
AI is thinking...
12. Illustrate the use of a static variable with a simple program. [5]
AI is thinking...