Tribhuwan University

Institute of Science and Technology

2082

Bachelor Level / First Year / Second Semester / Science

Bachelors in Information Technology (BIT153)

(Object Oriented Programming)

Full Marks: 60

Pass Marks: 24

Time: 3 Hours

Candidates are required to give their answers in their own words as for as practicable.

The figures in the margin indicate full marks.

Section A

Long Answers Questions

Attempt any TWO questions.
[2*10=20]
1.
Write a program to create a class Student with data members id, name, and marks. Define constructors to initialize data members and demonstrate constructor overloading. Implement member functions to read students details, display them and calculate average marks. [10]
2.
Explain inheritance with suitable example. Differentiate between single, multiple, and hybrid inheritance. Write a program to show constructor invocation order in multilevel inheritance. [1+4+5]
3.
Explain operator overloading with example? Write a C++ class Number to store an integer. Overload addition (+) and comparison (==) operators, and show conversion between int and Number. Write a program to perform these operations. [2+8]
Section B

Short Answers Questions

Attempt any Eight questions.
[8*5=40]
4.
Explain default arguments and inline functions in C++ with suitable examples. [5]
5.
What is the use of this pointer? Write a program to demonstrate it. [5]
6.
Explain friend function and friend class with example. [5]
7.
Differentiate between early binding and late binding. Write a program to show dynamic polymorphism using virtual function. [2+3]
8.
What are function templates? Also, write a program that swaps two values using function templates. [1+4]
9.
Explain ambiguity problem in multiple inheritance with example. How is it resolved using virtual base class? [5]
10.
Write a program to handle division by zero exception using try, catch, and throw. [5]
11.
Write a C++ program to read a text file named data.txt and display its contents on the screen. Also, count the number of lines, words, and characters in the file and display these counts after showing the file content. [5]
12.
What is the difference between abstract class and concrete class? Explain with example. [5]