2 1oop
2 1oop
'/ Candidates are requirecl to give their ansr.l'ers ir-r their or.r.n vu,ords as {ar as practicabie.
"/,lttem1tt A{! queslions.
.t the./igures in the margin indicate Full Marks.
./ ,4ssume suitable data if necessar)).
7 " \\,hy rve need virtual function? Explain rvith example, how you implement run time
polymorphism. 12+6)
8. trlow a file can be opened in C*+? Explain with a suitable example and Syntax. Write a
program to rvrite the Information of 10 emplo.vee in a file named " empioyee. dat", And
also scan the data from the frle and displa"v their details in console. [3+5]
{). What are the r"rse of Function lemplate'/ Write a prograrn to create a derive class r.vhich is
a non- template class from a base class which is a template class. [i+51
10. Horv is exception handling different than the traditional error hanciling? E,xplain the
exception handling constmct. Write a program to demonstrate exception handling with
"catch all". 12*2-41
:i**
TRIBHUVAN UNIVERSITY E_xam.
INSTtrTLTTE OF ENGINEERING Level BE Fult Marks 80
Examination Control Division art, ndr. Pass Marks 32 i
.."1
2079 Bhadra Vear i Part tl I Time 3 hrs.
___---_----_-__---_-i
i
'/ Candidates are required to give their answers in their orvn wouls as far as practicabie.
'/ Attempt All questions.
'/
'/
7'he Jigures' in the rnargin indit:ote {utt Mark{.
Assume suitahle data i/'neces.\'Ltrv
#rucE
1" Explain the basic concept of Object Oriented Programming. Compare C with C*+.
14+41
2. Define namespace in C**. What are conclitions r,lhere inline function may not work?
Write a program with function that takes twc arguments as reference anrl assign the
average of the irvo argutnents to the greater one and return that by reference. Call this
function by assigning value to the flunction and displa.v the vziiue of both argument. What
r,vill be the output? {Z+2+4)
3. What do you mean b3, "this" pointer? Create a class with a constructor ancl a Destructor
and show the operation or w'orking of constructors ancl clestructor using appropriate
blocks. [2-16]
4. What are fiiend class and I'rienC timction'l WAP to aclci prir"ate ciata of tyr,o different
classes using non-merlber iunctit-rn.
e+6)
5. List down the r:perators that carulot i:e overloadecl in f-*.
pxplain how a class type
(user'defined type) of data can be converted 1o a basic data (in-built ciata) type? Wriie a
pl'ogram to compare tu'o amoultt in Rupee b-v crverloading greater than (>) operator using
the concept ofoperator overloading.
[l+2+5]
6. What is the difference between pnvate and protected acoess specificr? Explain multi-path
inheritance with a suitable example.
e+61
7. What do you mean by poiymorphic class'l Wirat are dilferent RTTI mechanisms in C++?
Write aprogram that show,s the use of pure virlnal function. 1,2+2+41
8. What are the advantages of Random access over sequential access of file? Write a
program for transaction processing that write and read object randomly to and fiom a
random access file so that user can add and display the account information (account
number. last name, firstname. total balance)
V+6)
9. What do you mean by templates? Write down the syntax for function template and ciass
templates, Write a program with a class template to represent aray with member function
to sort the array eiements.
l2-r}+41
10. What are the reasons to use the exception handling rnechanism? Write a program to
handle multiple exception in C+*,
[3+51
*xa
TzuBHUVANUMVERSITY
INSTITLTTE OF ENGINEERING
Bxamination Control llivision
2078 Bhadra Year / Part
C;rndidates are required to give their answers in their own words as far as practicable.
At t e mp t 4!! q u e,r f i a n,s.
in the margin indit:ate tUtt Mar&s-.
The Jigure,s
Assume suitable Catu if necessary.
Write a program to multiply two complex numbers uiirg Object Oriented Approach.
lZ+Z+4)
2' Can we have more than cne constructors in a class'l If yes" explain the
neectr for such a
situation. Write a prLlgram designing a class called miclpoint t* lnC rnici-point
bctr,;v.,een
two points bv returning ub.iect liorn member function Lrsing this pointer.
[3+51
l" \Vily is namespace required? Explain how namespace is createci and used in pi:ogram with
a suitable exainple- Fiou'is reference variabie useci fi:r pass by let-erence?
fixpta;n. ll-i4+3J
4' Explain horv thc rtse of ilefault argument supports the function oyerloading rvitir
suitable
example' I)ellne inlinc 1i-rnction w:ith its merits and Cernerits.
[4*4]
5. Ilefinc operator overloading" Wliat. are the rules of operator oveiloaciing? l{cu, r1o yon
o"''erload urlarv operator? i:xplain with exampie. il.r2 r-5]
6' What are the cliff'erent forms of inheritance? Gir,e an example fbr each. \lirite
a progrcm
lr4rich contains a base class that ask the user to enter a complex nurnber
an{1 make a
deri"i'ed ciass that adds the comple,'. number of its cr,,r'n r.r,ith the
hase . Finalll, nialte tlii;:ii
class that is friend of derived and calcui;rte the cliiference af base
comple:< num6er and its
ov,,n complex nurnber
l3+SJ
7. Define virtual function r.vitl: suitable example. Expialri hou, dynamic
,cast and tS,peid
opel"ators :rre useil t() achiel,e RT'T'I. 15+31
8" Write shofi notes on file access pointers anil their rranipulators. Write prograin
a to make
silnple library managenlent s./steni of a college. Your prog.u* shauld
store and i:utrieve
the inibnnation (Ilook Narne, Book iD" Number of books anr.l purchase
date). lJ+51
9' Brielly explain impoitance of function template and class ternplate with suitable
example.
Write a program to create a rlerive class u,hich is a template from a
base c:lass which is
also a template with additional template parameters in the derived
class than that of the
base class.
[4+4]
i0. I&rhat is the advantage of having exception handling in the prograr:r?
Horr,, are multiptre
exceptions hanilled? Explain about Catching alt- exception
rnechanism.
in exceptir:rr handling
i 1+-?*1.l
J
L* I
***
TRIBHWAN TINIVERSITY Exam.
INSTITUTE OF ENGINEERING Level BE Full M*rks 80
Examination Control
tuII \.UIIlI Division
Ul IrlVfSIOn i programme
BEL, BEX, aa
BCI. BGE Pass Marks _1L
Canciid*tes are requii'ed tr-r give their answers in their o,,vn ra,ords
as far as pr
Attempt AU ques,tions.
The.figures iyt the. m*rgin indicate FUI\ fuIqbs.
As.sume suitcsble duta if necessary.
$t,!iSSl,_:_o-b-i-991o:gl"_.i_p'"ggef gi:ySfS:_:gU
'/ Candidates are required to give their answers in their own *'ords as far as
'/ Attempt 4Equestions.
/ The.figures in the margin indicate Fult Marks.
/ A,ssume ,suitable data i.f necessst'y.
Eiam. B:rcltt
]R] BH L \',\\ L,NIV ERSITY
Full Marks r:l
f\STllaiTE OF ENGINEERSTG Gvet =-- '-EE----
- I BEL,BEX' 3
Eramin ation Control Division Pqogramm" I iCf. SCg
3ks-
2075 Ashrvin T[arlPart III/l Time '
q!9"14
Jnented PtogrqryIlrng
CIri""tOnented
Subiect: - ObJIgt Programming pr50l)L
(Cr:!l
-*,h1"*
own words far as practicable'
. r a-rdidares are required to give their answers in their
as
Lrlkqt:9-bie*
practicable'
Candidates are required to give their answers in their own words as far as
Attempt All questions.
The figures in the margin indicate Full Marks.
Assume suitable data if necessarY.
l. What are the advantages of object oriented programming over procedural programming
progam_
language? Explain the features of object oriented programming. Write a simple
concept'
that iilustrates the object oriented 12+3+31
Z. Why do we need friend function? Explain how any member function of a class can be
niena of otherclass with a suitable example. 12+61
B. Discuss about stream class hierarchy. How a file can be open in C#. Explain with
in
suitable example and syntan. Write a program to write the Information of 10 employee
a file. And also displaytheir details inconsole. [2+2+41
g. Explain why do we need template. Explain the function template overloading with
,uitubl" example. [3+5]
10. Explain about all Exception Handling constructs. With suitable example explain multiple
exceptions handling in-C++. [3+5]
!F:f !F
",*
25 TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
I*:el . iFE _ _. 1pfll*ijh"
Examination Control Division BEx' Bcrl pa*
2074 Ashwin
l::*:::
Programmr i 3:b '"*_'"'!
J ffib' --* I:"
lqrir Frii-- l- ii ii"*--**
Mrrkr
I'trlrre
r' Candidates are required to give their answers in their own words as far as practicable.
{ Attempt AI! questions.
1' what are the advantages of object oriented programming over procedural programming?
Describe
the characteristics of OOp.
[4+61
'\'/ 2' Explain how the use of default argument supports the function
overloading with suitable example.
Define namespace with its significance
[s+5]
3' Explain the relation between constant object and constant function
with example. When do we use
static data nrember and static function in a crass? Exemptifu.
[s+sl
4' How do you convert user-defined data type to a basic data type?
write a program to overload the
relational operators to compare the length (in meter and centimeter)
of two oblects.
Ia+5J
5' How the function over'riding differ from function overloading? Explain.
Write a program to show the
order of constructor invocation in multilevel inheritance.
[5+S;
6' Explain abstract class with example. Exptain how dynamic cast and
typeid operators are used to
achieve Rfit.
Is+sl
7. What are different ios functions used in stream l/O?How they are
different from manipulators? Write
a program to store and retrieve the information of patient (Patient_tD,
narne, address, age and typelin
hospital ma nage me nt syste m.
[3+2+51
8' How do you use ctass template with multiple template type? How
the exception is re-thrown during
exception handling?
[5+5J
tF*ih
'*
22 TRIBFIUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
Examination Control Division
2073 Shrawan 3 hrs.
1. Explain the characteristics of OOP. Write a program to create class "time" with data
mernbers hours, minute and second. Then add two "time" objects by taking object as
argument and also retuming object as argument [4+6]
2. Why don't you use an object to call the Static Member Function, explainwith example?
Why do you need to use a reference in the argument to the copy constructor? Write a
program to calculate the Perimeter of Triangle using Default and Parameterized
constructors. [4+3+31
J. When inline function may not work? What do you understand by Default Arguments?
Write syntax of 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 number of characters to be printed. [2+2+2+47
4. Explain the syntax of operator overloading. Create a class named City that will have two
member variables CityName (chart[zO]) and DistFromKtm (float). Add member functions
to set and rehieve the CityName and DistFromKtm separetely. Add operator overloading
to find the distance between the cities (ust find the difference of DistFromKtm) and sum
of distance of those cities form Kathmandu. In the main function, initialise three city
objects. Set the first and second city to be Pokhara and Dhangadi. Display the surn of
DistFromKtm of pokhara and Dhangadi and distance between.pokhara and Dhangadi. [3+7]
5. What do you mean by frrnction overriding and how can we access every overridden
function from the derived class object? Explain with example. Write a program to show
the execution order of constructor and destructor in multilevel inheritance. Show 1'our
program outputs. [5+5]
6. What are the different ios class functions and flags that are used for formatted VO
operation? Write a program to read and write the information of 10 students in a file. Also
modifu the student information according to the given roll number. [3+7]
7. What do yoi mean by Class Template and Function Template? Write down the synta,x of
Class Template and Function Template. Write a program to read your Date of Birth and
display it. Your program should throw multiple exception for day, month and other values
not in nmge using exception class and each exception is handled by separate handler. l2+2+6J
8. Explain different manipulator available in C+r. Create class student to store Name, Age
and CRN of students. Write a program to write records of N numbers of students into the
file. And your program should search complete information of students from file
according to CRN entered by user and display it. [4+6]
* *,F
:*
TRIBHUVAN UNIVERSIry iExam.
t.-'...-..*.
Full Marks
INSTITUTE OF ENGINEERING
Examination Control Division
2072 Chaitra
$ubigct;--oH-g:!-qggolg-93-*ryni"s!9!!0-!)
Candidates are required to give their answers in their own words as far as practicable'
Attempt r4ll que stions.
The.figares in the margin indicate Full Marks'
Assume suitable data if necessary.
2. Define constructor. Why constructor is needed for a class? Explain about different types
of constructor with a tritubl* program' U+2+'71
a
J. Write down the significance of reference variable with suitable example. Define default
argument. Write u p*grurn to show the relation between default argument and firnction
oierloading. 14+2+47
4. Why do we need operator overloading? What are the non-over loadable operators in
Cai? Write a program that will convert object from a class Rectangle to object of a class
Polar using Casting Operator. 12+2+61
5. Explain the need of virtual base class with suitable example. Create a derived class
manager from two base classes person and employee. Assume suitable data members in
each Jlass and display the information. [5+5]
6. Explain about stream class hierarchy by highlighting the different ios flags and their
*ug". Write a program to make billing system of a department store. Your program
shouta store and retrie'tre data to/from files. Use manipulators to display the record in
proper formats. [3+7]
7. Why clo you need Virtual Destructor? Explain with example. Write a progriim having
polygon as an abstract class with Lenglh and Height as its data member. Create derived
class Rectangle and Triangle. Make Area $ as pure virtual function and redefined it in
derived class to calculate respective area. [4+61
8. Define function template and ciass template with respective syntax. Write a program to
find the square root of given number. Check the validity of input number and raise the
exception * p"r requirement. [5+5]
" **:F
t
Examination Control Division Programme BEL, BEX, BCT, BGE Pass Marks 32
2072h{artik Year / Part II/r Time 3 hrs.
l. What is. data absuaction? Compare it with encapsulation in C**. With suitable example,
explain the concept of class in C**. l2+2+61
'.
/r :::__:i"' .. ..
. ..
",
Li What is the 4.{vantage of C* over C? With suitable e4..a.q1p-l,g.gxplain dynamic memory
allocation for object and object arrd;y.'
::::'i".
3. What is a default argumemt? What are the advantages and disadvantages of using inline
frrnction? Write a prograno. to calculate and display the cube of integer, float and double
number using function overloading (passing single argument to [4+3+3] function).
4. Write dov,rn syntar of operator overloading for various cases. Develop a progftrm using a
class towith3x3 matrix as a data mernber. Overload the * operators so as multiply two i
matrices. l3+71
5. -What.is.difference-bet"wea-overloading-"andoverriding?..W"ith'suitable-examplE'cxplain -
hybrid inheritance. [4+6]
6. Discuss about stream class,hierarchy. Write a program for hansaction processing that
write and read objecl randdmly to and from a random access file so that user can add,
update, delete and display ttre account information (accountnumber, lastname, firstname,
totalbalance). t3+7)
t J. Explain the reason for mmber fturction over-riding when using virttral function. Explain
RT'[I using dynamiCcastand typeid operators with suitable example [5+5]
8. E4plain class tanplate with suitable.example. Hoy dg':r y.gq handle multiple
r!':::':{i'i;r; exceptions in
:' I ': - j -::"i::j" '
c+? Explain with example. {5+5}
.J-].,...::-.-::.-,-*',-::.]::i-.j,]:il.:.-j]:.-:1]].::j
,
t,
t"tt"''
' :,;"
:- '
'
_."-;:.^,
".qS .
"' r::'r-i :i.
i 1; "'r*_ "_' -W
,1:.".1'',
{.
: j ir"
,'-.,4$',14*
'-1:l *.':
.r:,1.iF; -
t+++'-
ilr':
,,,S. :+;;'r.
.1.
.'
4
l. Write down the limitations of procedural programming. Compare procedural and object
oriented programming. Write program to find prime number in procedural and object
oriented waJs. [2+2141
2. What do you understand by friend functions and classes? Explain with example. Write a
program to add members of objeots of trro differcnt classes.
L4+61
3. What do you mean by namespace? Explain how namespace can be used. Write I program
that uses pass by refercnce to change meter to centimeter using pass by reference along
with the namespace. [2+2+61
4. Explain the binary and unary operator overloading along with their syntax and example.
Write a program to add two matrices by overlohding the + operator.
[4+61
5. Explain the construcor and destructor invocation onder in single and multiple inheritance.
Also show how a parameterized base class constructor is calted when derived class object
asi created. Write a pmgram to create classes to represent student, teacbing staffs and non-
teaching staffs from the base class person. Use proper members in the classes to make your
program meaningful [4+6]
6. What do you mean by manipulcors? Explain different manipulators available in C#.
Write a program that stores information of a students in a file and display the file's cont€nt
in descendingorder according to their marks obtained. , lt +3+61
7. What are virtral functions and pure virtual functions? Explain abstract class and its use.
t \Yrite I prograri having shrdent as an abstret class and create deriv€d class such as
Engineering Sciencc and Medical. Show the use of virtual functions in this program. l2+2+67
8. What do ygu un<lerstand by function template? Write down the syntax and usc of function
ternplate. Wrirc a program that will find the sum and average of elements in an array using
[2+2+6)
function templates.
*+!t
;t
22 TRIBHWANI'NIVERSITY Exam. Itcgtrlit r'
INSTITUTE OF ENGINEERING Level BE Full Marks 80
I. What are the benefits of object oriented programming over procedure oriented
programming? Describe the features of object oriented programming. What is the task of
constkeyboard? L4+4+21
2. List the feature of C*. What are constructors, write their use and explain using an
example. [4+6]
3. What is dynamic memory allocation? Write a C** program to join two strings using
dynamic constuctor concept. 13+71
4. What is the disadvantage of using operator overloading in C++? Write a program to
define a Class Distance with necessary data members and functions. Then overload the
relational operators to compare the two objects of Distance class. [2+8]
5. What is a protected access specifier? Write a program with three classes students, test and
result by using multilevel inheritance. Assume necessary data members and functions
yourself and progam with input information, input data and calculate marks total and
display result. 13+71
6. List the features that are used in formatting the output. Explain each with example. t10l
7. Why do we need virtual firnction? Explain with suitable example. What is pure virtual
fi,rnction? What is the task of reinterpret cast operator? 16+2+21
8. Explain the importance of function template with suitable example. How default
arguments can be used in class template? What are the tasks of try, catch and throw
block? [4+3+3]
{.,r:F
23 TRIBHI-ryAN UNIVERSITY Exam. Ilcgul:rr
INSTITUTE OF ENGINEERING Level BE Full Marks 80
BEL, BEX,
Examination Control Division Programme
BCT
Pass Marks 32
I What are the characteristics of OOP? How does the OOP differ from POP?
Using object oriented technique, write a progrum to create aclass vector
that reads integer number. Perform vector addition by passing object as
t 3+2+5 I
arguillent and returns the object as result. A vector is a class with array as member..
7. Explain the need of virtual function with suitable example. Wtrat do you
mean by run -time type information (RTTI)? How dynamic cast and
15+2+31
rypeid operators arc used to achieve RTTI?
8. Define class template and t'unction template with respective syntax. What
are the different exception handling techniques in C++? F,xplain with
appropriate example. 15+2+31
,1. *,t
I
I
I
n
t-
t
\
t
.t
ect Oriented
'/ Candidates are required to give their answers in their own words as far as practicable.
/ Attempt fllquestions.
- '/ Thefigures in the margin indicate Full Marks.
/ Assame suitable data if necessary.
t. Cortrpare C and C+r. Write down different features of C+r with example for each. [5+5]
2 What do you understand by the static data member and member functions? Explain their
E
use in.the program. Write a progmm that uses static member functions and static data
member. 12+2+61
3. What do you understand by default argume,nts? Replace. the function with default
argument with function overloading. Write a program to find the area of triangle (when
three sides are gtven) and area of rectangle using function overloading and default
argument. . 12+2+61
4. What are the overloadable operators in C#? Write down the syntax for operator
overloading in different cases. Write a program to compare the magnitude of complex
.,,
nnmbers by overloading and
- operators. t2+2+6J
5 Explain different tlpes of access specifiers used in inheritance. Explain the case of
arnbiguity in inheritance. Write a program that shows ambiguity in multiple,inheritance. 12+2+6)
-6. What do you mean by stream? Explain different stream class for file input/ouput. Write a
program to display the ouput in pyramid from aq
-t
follows: . 12+2+61
,t Ar
lAB
ABCD
'':. . What do you mean by polymorphic class? What are different RTTI mechanisms in C+?
Write a program that shows both RTTI mecha',isms t2+2+61
_8. What do you mean by templates? Write down the syntax for function template and class
templates. Write a program with a clasi template to represent array and add rpember I
functions to find ma:<imum, minimum and sort the generic array. 12+2+6)
**rl.
,'
i-
{ Candidates are required to give their answers in their own words as far as practicable.
I Aaempt All questions.
{ Thertgures in the margin indicate Full Marks.
,/ Assume suitable data if necessary.
L What is encapsulation? What are its advantages? How can encapsulation be enforced in
C++? Write u progru* to create a class LandMeasure that readsRopani, Ana, Paisa and
Dam as data members. Write a function to pass two objEcts of type Land Measure and
return their sum. (16 Ana = I Ropani, 4 Paisa: I Ana,4 Dam: I Paisa) t1+l+2+6]
2. What function'overloading? Use neu, and delect operators to store n numbers
is
dynamically and find their average using casting operator. What are the things we should
remembqr while using default argument. Explain with an example. [2-r5 +3]
3. What do you mean by friend function and friencl class? Do friends violate encapsulation?
'Write a program that can store Department ID and Departrnent name with constructor.
Also write destructor in the same class and show that objects are destroyed in reverse
order of creation with suitable message [2+3+5J
4. List the operators which cannot be overloaded. Why does the overloading of binary
operator with member firnction requires only one argument? Create a class having an
array as mernber. Overload index operator ([ ]) to input and display the elements in the
ffray. 12+2+,61
5. How do you access overridden members of the base class from a member function in the
derived class? What is the problem faced when using multipath inheritance and how is it
solved? Explain with an example the order of constructor and destructor invocation
during multiple inheritance.. t2+i'-31.
6. What are the primary trade offs benryeen static and dynarprc binding? What is pr.re virtual
function? Write a firnction template for the function power( ) which has two,parameters
base and exp and returns base"*P. The type.of base is the parameter to the template and
exp i3 int. If the exp is negative, then it must be converted to its positive equivalent. For
example 23 and2-3 must both return 8, t2+2+67
7. What is a file strearn? Write a class student with roll, name, address, marks as member
variables. Use a member function to write records of students in a binary file and another
member function to read records from file. Write a program to search a specific record of
student using roll number as key from user input. [2+8]
8. What are the advantages oi Exception Hanclling;over Conventional Error Handling
mechanism? Explain the constructs for Excepion Handling in C++ with an example.
Write a meaningful program illustrating the use of both Exception with argument and
Excepion Specification for function. [3+3+4]
*!F!k
2_