Object Oriented Programming 2080

Question Paper Details
Tribhuwan University
Institute of Science and Technology
2080
Bachelor Level / Second Semester / Science
Information Technology ( Na )
( Object Oriented Programming )
Full Marks: 60
Pass Marks: 24
Time: 3 hours hours

Section A

Long Answer Questions
Attempt any TWO questions. [2 × 10 = 20]

Official Answer
AI Generated Answer

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]

10 marks
Details
Official Answer
AI Generated Answer

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]

10 marks
Details
Official Answer
AI Generated Answer

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]

10 marks
Details
Official Answer
AI Generated Answer

AI is thinking...

Section B

Short Answer Questions
Attempt any EIGHT questions. [8 × 5 = 40]

Official Answer
AI Generated Answer

AI is thinking...

4. What is the difference between public, private, and protected inheritance in C++? [5]

5 marks
Details
Official Answer
AI Generated Answer

AI is thinking...

5. What is exception handling? Explain types of exception handling and provide a suitable example. [1+4]

5 marks
Details
Official Answer
AI Generated Answer

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]

5 marks
Details
Official Answer
AI Generated Answer

AI is thinking...

7. Write a program to demonstrate returning an object from functions in C++. [5]

5 marks
Details
Official Answer
AI Generated Answer

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]

5 marks
Details
Official Answer
AI Generated Answer

AI is thinking...

9. Write a program to read and write values through an object using file handling. [5]

5 marks
Details
Official Answer
AI Generated Answer

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]

5 marks
Details
Official Answer
AI Generated Answer

AI is thinking...

11. Differentiate between function overloading and function overriding in C++. [5]

5 marks
Details
Official Answer
AI Generated Answer

AI is thinking...

12. Illustrate the use of a static variable with a simple program. [5]

5 marks
Details
Official Answer
AI Generated Answer

AI is thinking...