Tribhuvan University

Institute of Science and Technology


Bachelor Level / second-semester / Science

Computer Science and Information Technology( CSC166 )

Object-Oriented Programming

Full Marks: 60 + 20 + 20

Pass Marks: 24 + 8 + 8

Time: 3 Hours

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

The figures in the margin indicate full marks.

Section A

Attempt any two questions.


When inline functions may not work? Define and write syntax for default arguments. Write a program to display N number of characters by using default arguments for both parameters. Assume that the function takes two arguments, one character to be printed and other how many times the character to be printed respectively.


State the use of new operator. An educational institute wishes to maintain a data of its employee. The hierarchial relationships of related classes are as follows.

- Hamro CSIT

Define all the classes to represent above hierarchy and define functions to retrieve individual information as and when required.


What is constructor? Why constructor is needed in a class? Illustrate the types of constructor with an example.

Section B

Attempt any eight questions.


Write a C++ program to display the number of objects created using static member.


Explain about friend function and friend class with an example.


What is the use of reinterpret cast operator? Why do we need virtual function?


Differentiate between concrete class and abstract class. Define class template and function template with syntax.


Describe the chain of constructors and destructors in inheritance.


List any two operators that cannot be overloaded. Write a program to handle the possible exception in taking “age” as input. Here the exception must be thrown in the input is negative or greater than 200.


Create a class named Point with data members x(int) and y(int). Add operator overloading to find the Euclidean distance between two points.


Explain the reason for member function overriding when using virtual function.


What do you mean by stream? Explain different stream class for file input/output.