Tribhuvan University

Institute of Science and Technology

2080

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.

1

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.

2

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.

3

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

Section B

Attempt any eight questions.

4

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

5

Explain about friend function and friend class with an example.

6

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

7

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

8

Describe the chain of constructors and destructors in inheritance.

9

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.

10

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

11

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

12

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