0 ratings 0% found this document useful (0 votes) 23 views 20 pages Object Oriented Programming
The document outlines examination questions for Object Oriented Programming at Tribhuvan University, covering various topics including C++ features, constructors, inheritance, operator overloading, templates, and exception handling. Candidates are instructed to provide answers in their own words and assume suitable data where necessary. The exam consists of multiple questions requiring programming examples and explanations of concepts related to OOP.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Carousel Previous Carousel Next
Save Object Oriented Programming For Later ‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
Full Marks | 80
Pass Marks | 32
Candidates are required to give their answers in their own words as far as practicable,
Y Attempt All questions,
Y The figures in the margin indicate Full Marks.
Y Assume suitable data ifnecessary,
What are the limitations of Procedure Oriented Programming? Explain features of C++.
Write a program to multiply two complex numbers using Object Oriented Approach. [24244]
2. Can we have more than one constructors in a class? If yes, explain the need for such a
situation, Write a program designing a class called midpoint to find mid-point between
two points by returning object fiom member function using this pointer. B43]
3. Why is namespace required? Explain how namespace is created and used in program with
suitable example, How is reference variable used for pass by reference? Explain, _[1+4#3]
4, Explain how the use of default argument supports the function overloading with suitable
example, Define inline function with its merits and demerits. [444]
5. Define operator overloading. What are the rules of operator overloading? How do you
overload unary operator? Explain with example. (14245)
6. What are the different forms of inheritance? Give an example for each. Write a program
which contains a base class that ask the user to enter a complex number and make a
derived class that adds the complex number of its own with the base. Finally make third
class that is friend of derived and calculate the difference of base complex number and its
own complex number. [3+5]
7. Define virtual function with suitable example, Explain how dynamic_cast and typeid
operators are used to achieve RTT. [543]
8. Write short notes on file access pointers and their manipulators. Write a program to make
simple library management system of a college. Your program should store and retrieve
the information (Book Name, Book ID, Number of books and purchase date). B45]
9. Briefly explain importance of function template and class template with suitable example.
Write a program to create a derive class which is a template from a base class which is
also a template with additional template parameters in the derived class than that of the
base class. [444]
10. What is the advantage of having exception handling in the program? How are multiple
exceptions handled? Explain about Catching all exception in exception handling
mechanism. [24343]
He‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
Examination Control Division | programme
Full Marks | 80
| Pass Marks | 32
2075 Chaitra
Y Candidates are required to give their answers in their own words as far as practicable,
Y Attempt All questions
Y The figures in the margin indicate Full Marks,
¥ Assume suitable data if necessary.
1. What are the main features of Object Oriented Programming? Would you consider it
better than structured programming? If you do, what makes it better? Write down its
advantages and disadvantages, [24343]
2. What do mean by constructor and destructor? Explain the necessity of copy constructor
with example. Also explain order of invocation of constructor and destructor with
example. [24343]
3. What type of language is C+? Explain its features. (2+6]
4, What is function overloading? How is pass by reference done in C++, Explain with,
suitable example. [2+2+4]
5, Write syntax of operator overloading. Create a class called time that has separate int
member data for hours, minutes, and seconds. One constructor should initialize this data
to zero (0), and another should initialize it to fixed values. A member function should
display it in 10:45:30 format. The final member function should add two objects of type
time passed as arguments using operator overloading, t+)
6. How the function over-riding differ from function overloading? When do we face
ambiguity problem in multiple inheritance? Explain, [44]
7. What is pure virtual function? Discuss the role of virtual functions in C++ to cause
dynamic polymorphism. Show with example how it is different from the compile time
polymorphism. [24244]
8, What are different file access pointers? Write a program to store and retrieve the
information of Client(Client_ID, Account_ID, name, address and age) in Bank
management system. Also calculate the total number of clients in a bank. [246]
9. Explain function template? How do you use function template with multiple template
types? Give ‘example. [4+4]
10, What is exception and what is the mechanism of exception handling in C++? Write a
program to illustrate the process of handling multiple exceptions. [26]
see‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
2076 Ashwin
____ Subject:
Object Oriented Programming (CT 50i) _
Y Candidates are required to give their answers in their own words as far as practicable.
Y Attempt All questions.
Y The figures in the margin indicate Full Marks,
Y Assume suitable data if necessary,
1. What are benefits of object oriented programming over procedural language? [44343]
Compare C+ with C. List out the features of C+,
2. What is a constant function? What is its relation with constant object? Writea [2#2+6]
meaningful function that shows the use of constant object and constant function
along with use of const cast operator.
3. What do you understand by default arguments? How can you relate default (242+6]
argument function with function overloading? Write a program to find volume of
different shapes using function overloading.
4, What do you mean by operator overloading? Write down its syntax. Write a class [242+6]
that represent the distance class and overload +++ and ~- operator to increment and
decrement distance.
5, Explain the need inheritance in programming? Explain various forms of [24246]
inheritance. Write a program to create a derived class by inheriting two base
classes with same function names, Your program should be complete and
meaningful.
6. What is the purpose of stream manipulation? Explain different file modes that are (2+2+6]
used in opening the file. Write a program that will copy the content from one file,
change the case of letters to upper case if they are in lower case and store in next
file,
7. What do you mean by polymorphic class? What are different RTTI mechanisms [2+2+6]
in C++? Write a program that shows the use of pure virtual function.
8. Why do we need class template? Write a program to create class to represent B+)
stack data structure and use exception handling to control empty and full cases.15 ‘TRIBHUVAN UNIVERSITY
Examination Control Division
55
10.
INSTITUTE OF ENGINEERING
2074 Chaitra
~ Subject: - Object Oriented Programmi ing (CTS01)
Candidates are required to give their answers in their own words as far as practicable.
Attempt All questions.
The figures in the margin indicate Full Marks,
Assume suitable data if necessary.
What are the advantages of object oriented programming over procedural programming
language? Explain the features of object oriented programming. Write a simple program
that illustrates the object oriented concept. [24343]
Why do we need friend function? Explain how any member function of a class can be
friend of other class with a suitable example. 246]
Explain the features of C"*.What is namespace? Explain how memory is allocated and
deleted dynamically for normal variable and for array in C** with example program. [2+1+5]
Explain why default arguments are used with functions, How can a function with default
argument be implemented with function overloading? Explain with example. B45]
Define operator overloading. Write operator functions as member function of a class to
‘overload arithmetic operator +, logical operator ‘<=" and stream operator *<<’ to operate
on the objects of user defined type time (hr, min, sec). 7)
What is Ambiguity and function Overriding? How they can be resolved? Explain each
with a suitable example. [44]
‘What is pure virtual function and abstract class? With suitable example explain run time
polymorphism. B45)
Discuss about stream class hierarchy, How a file can be open in C++. Explain with
suitable example and syntax. Write a program to write the Information of 10 employee in
afile. And also display their details in console. [24244]
Explain why do we need template. Explain the function template overloading with
suitable example. [B+5]
Explain about all Exception Handling constructs. With suitable example explain multiple
exceptions handling in C+. [+5]INSTITUTE OF ENGINEERING —_[ Level BE [Full Marks | 80
Examination Control Division | programme oe ae Pass Marks | 32
2075 Ashwin [Yea m/T Time hrs.
~ Subject: - Object Oriented Programming (CT501)
Candidates are required to give their answers in their own words as far as practicable.
Attempt All questions.
The figures in the margin indicate Full Marks.
Assume suitable data if necessary.
Why object oriented programming is necessary in Programming? With suitable example,
explain the importance of object as function argument and returning object. +5]
2. What do you mean by construetor? Explain different types of constructors, Create a class
called ‘time’ with data member hour, minute, second and day. Initilalize all the data
member using constructor. Write a program to add two time object using necessary
member functions and display the result. [14245]
3, Compare C and C++. Why do we need dynamic memory management? Explain the
operators in C++ that enables dynamic memory management with example. (2+2+4]
4, What is Token, write its details? With example explain function overloading in object
oriented programming. B45]
5. Explain which operators cannot be overloaded in c++? Explain how a Class type (user-
defined type) of data can be converted to a basic data (inbuilt data) type? Write a program
to concatenate two user given string by overloading binary plus (+) operator. [14245]
6. Explain why inheritance is important in object oriented programming? With suitable
example write details on member function overriding? B45]
7. Explain compile-time and run-time binding. Differentiate abstract base class and concrete
class, Write an abstract class of your choice and use it in a program. Your program should
be meaningful. [14245]
8. Sequential and random access are two methods to access a data file. Which one do you
prefer and why? Write a program to show opening, reading objects from file, checking
end of file and closing the file. [444]
9. Why template is important in C++ programming? Write a program using template to add
two numbers. Use the function template to pass integer, float and double. Display the
returned result, [3+5]
10. How is exception handling mechanism better than traditional error handling? Explain
how the exception is rethrown with a suitable program. +5]
see25 ‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING se
Examination Control Division | programs: | ae BEX, BCT,
2073 Chaitra var/Part | Il
~_ Subject: - Object Oriented Programming (CT501)_
Candidates are required to give their answers in their own words as far as practicable.
Attempt All questions.
The figures in the margin indicate Full Marks,
Assume suitable data if necessary.
1. What are the advantages and disadvantages of object oriented programming over
procedural programming? Briefly describe the features of C+. [545]
2. Define dynamic memory allocation. How do you use it in C++? Explain reference
variable with suitable example. Write a program to swap two numbers using pass by
reference concept. [124344]
3. Define ‘this’ pointer with its applications. Explain the order in which constructor and
destructor are invoked with suitable example. 15+5]
4, Define operator overloading. What are the rules of operator overloading? How do you
overload unary operator? Explain in detail with example. [14247]
5, What is function over-riding? How scope resolution is used with over ridden function?
Explain the need of virtual base class with suitable example. [24345]
6. Write short notes on the access pointer and their manipulators. Write a program to make
simple library management system of a college. Your program should store and retrieve
the information (Book Name, Book ID, Number of books and purchase date). [446]
7. Expiain the need of virtual function with suitable example. Define runtime type
information (RTT). How dynamic cast and typeid operators are used to achieve RTT? [4+2+4]
8. Explain how default arguments are used with class template with example. How do you
throw only specified exception from a function? Exemplify. (5+5]25 TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING [Level
Examination Control Division | Programme
2074 Ashwin (Year /Part
ae > Object Oriented Programming (C7501) _
Y Candidates are required to give their answers in their own words as far as practicable.
¥ Attempt All questions,
Y. The figures in the margin indicate Full Marks
¥ Assume suitable data if necessary.
What are the advantages of object oriented programming over procedural programming? Describe
the characteristics of OOP. (a6)
. Explain how the use of default argument supports the function overloading with suitable example.
Define namespace with its significance. [545]
Explain the relation between constant object and constant function with example. When do we use
static data member and static function in a class? Exemplify. (5+5]
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 objects. [446]
. How the function over-riding differ from function overloading? Explain. Write a program to show the
order of constructor invocation in multilevel inheritance. [545]
.. Explain abstract class with example. Explain how dynamic cast and typeid operators are used to
achieve RTT. [5+5}
+ What are different ios functions used in stream |/O?How they are different from manipulators? Write
‘program to store and retrieve the information of patient (Patient_ID, name, address, age and type)in
hospital management system. (34245)
. How do you use class template with multiple template type? How the exception is re-thrown during
exception handling? [545]
wee25 ‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING | Level BE 80,
Examination Control Division | programme | 3ELB®% ® a2 |
2072 Chaitra (Year7/Part [M/1 hrs.
. u Object Oriented Programming (CT50/)
Y Candidates are required to give their answers in their own words as far as practicable,
Y Attempt All questions.
Y The figures in the margin indicate Full Marks
¥ Assume suitable data if necessary.
1. Explain main characteristics of Object Oriented Programming. Write a program to find
the transpose of given Matrix using the concept of Object Oriented Programming. (5+5]
2. Define constructor. Why constructor is needed for a class? Explain about different types
of constructor with a suitable program, [14247]
3. Write down the significance of reference variable with suitable example. Define default
argument, Write a program to show the relation between default argument and function
overloading. [44244]
4, Why do we need operator overloading? What are the non-over loadable operators in
C++? Write a program that will convert object from a class Rectangle to object of a class
Polar using Casting Operator. [24246]
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 class and display the information. [545]
6. Explain about stream class hierarchy by highlighting the different ios flags and their
usage. Write a program to make billing system of a department store. Your program
should store and retrieve data to/from files. Use manipulators to display the record in
proper formats. G+)
7. Why do you need Virtual Destructor? Explain with example. Write a program having
Polygon as an abstract class with Length 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+6]
8. Define function template and class 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 as per requirement, [545]
ae2 ‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
Examination Control Division | Programme |BGE
2073 Shrawan
Y Candidates are required to give their answers in their own words as far as practicable.
Y Attempt All questions.
v The figures in the margin indicate Full Marks.
Y Assume suitable data if necessary.
1. Explain the characteristics of OOP. Write a program to create class "time" with data
members hours, minute and second. Then add two "time" objects by taking object as
argument and also returning object as argument. (4+6]
2. Why don't you use an object to eal! the Static Member Function, explain with 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. [44343]
3, 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+4]
4). Explain the syntax of operator overloading. Create a class named City that will have two
member variables CityName (chart[20}) and DistFromKtm (float). Add member functions
to set and retrieve the CityName and DistFromKtm separetely. Add operator overloading
to find the distance between the cities (just 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 sum of
DistFromKitm of pokhara and Dhangadi and distance between pokhara and Dhangadi. (3+7]
5, What do you mean by function overriding and how can we access every overridden
funetion from the derived class object? Explain with example, Write a program to show
the execution order of constructor and destructor in multilevel inheritance. Show your
program outputs. [5+5]
6, What are the different ios class fimctions 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
modify the student information according to the given roll number. B+]
7. What do you mean by Class Template and Function Template? Write down the syntax 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 range using exception class and each exception is handled by separate handler. [2+2+6]
8. Explain different manipulator available in C++. 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 [446]
wee28 ‘TRIBHUVAN UNIVERSITY (Exam.
INSTITUTE OF ENGINEERING evel se, Full Marks. | 80
Examination Control Division | Programme | 3&1, Bex, 8cT, BGE| Pass Marks | 32
- Object Oriented Programming (C750) SS
Candidates are required to give their answers in their own words as far as practicable.
Attempt All questions.
The figures in the margin indicate Full Marks,
Assume suitable data if necessary.
Explain the advantages of OOP over traditional procedure oriented programming. What are
the characteristics of OOP? Write a program to perform addition of two metric distances
which takes object as argument an also returns object as argument. [24345]
What is literals and identifier? What is function overloading? Write a program to find the
area of circle, rectangle and square using function overloading. [44244]
Listidown the difference between constructor and destructor. Write a class that can store
Depiirtment ID and Department Name with constructors to initialize its members., Write
destructor member in the same class and display the message "Object goes out of the scope".
Your program should be made such that it should show the order of constructor and
destructor invocation. B47]
Explain how you overload relational operator using member function and non-member
function. Write a progam to convert currency from dollar to rupees and vice versa (assume ~
suitable data). « [446]
What do you mean by:access specifier? Explain how difféentspecifiers can be used in the
inheriting features of base class members. Write syntax for each one of them and Write a
program to support your explanation. [13+7]
Explain class hierarchy for console and file /O with diagram. What are different ios class
functions and flags that are used for formatted 1/O operation? Write a program to read and
write the information of 10 students in a file B34]
What is pure virtual function? Write a program to demonstrate rintime polymorphism in C**[44+6]
What is rethrowing exception? Write a program usiig template to add two integers, two
floats and one integer and one float respectively. Display the final result in float, (9)
eee28 “TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
Examination Control Division
2072 Kartik
Candidates are required to give their answers in their own words as far as practicable.
Attempt All questions.
The figures in the margin indicate Full Marks.
Assume suitable data if necessary.
1. What is data abstraction? Compare it with encapsulation in C**. With suitable example,
explain the concept of class in C™*. [2+2+6]
2. What is the advantage of C’* over C? With suitable example explain dynamic memory
allocation for object and object array. [446]
3, What is a default argument? What are the advantages and disadvantages of using inline
function? Write a program to calculate and display the cube of integer, float and double
‘number using function overloading (passing single argument to function). [44343]
4. “Write down syntax of operator overloading for various cases. Develop a program using a
‘lass to: with 3x3:matrix:as.a'data- member. Overload the *-operators so.as multiply two
matrices. [3+7]
i 5, \What is difference between overloading and overriding? With suitable example explain
| hybrid inheritance. [446]
\ 6, ‘Discus about stream ‘class hierarchy. Write-a program for transaction processing that
} write and read object randomly to:and from:a°random access file so:that user can add,
t update, delete and display the account information (accountnumber, lastname, firsmame,
1
totalbalance). B+]
7. Explain the reason for member function over-riding when using virtual function. Explain
RTT using dynamic cast and typeid operators with suitable example. [545]
8, Explain class template with suitable example. How do you handle multiple exceptions in
C*"? Explain with example. {5+5]
oe‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERIN
Examination Contro! Division
2070 Chaitra
~ Subject:
Candidates are required to give their answers in their own words as far as practicable,
Aitempt All questions.
The figures in the margin indicate Fudd Marks.
Assume suitable data if necessary.
S84 |
| What are the benefits of object oriented programming over procedure oriented
programming? Describe the features of object oriented programming, What is the task of
const keyboard? = ; [4422]
List the feature of C** What are constructors, write their use and explain using an
example. [446]
What is dynamic memory allocation? Write a C™* program to join two strings using
dynamic constructor concept. B+7]
|. 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. [248]
“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 program ‘with input information, input data and calculate marks total and
display result. . +7
6." List the features that are used in formatting the output. Explain each with example: [10]
Why do we need virial function? Explain with suitable example, What is pure virtual
function?. What is the task of reinterpret cast operator? [64242]
8. Explain the importante 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? = [44343]
wee22° TRIBHUVAN UNIVERSITY | Exam.
INSTITUTE OF ENGINEERING Level
Examination Control Division | Programme | BEL 8EX,BCT, BGE
2071 Shawan Ti
Subject.
Y Candidates are required to give their answers in their own words as far as practicable. 2
¥ Attempt All questions. ’
Y The figures in the margin indicate Full Marks, 5
Y Assume suitable data if necessary. :
1. What is Object Oriented Programming? What are the drawbacks of Procedure Oriented
Programming? List down the features of C++. Write @ program with a class to represent.
distance with fect and inches members .he class should have member Functions to read
and display the data members and member functions to add and subtract two distances: (124245)
2. What do you mean by namespace and what isits use? Explain about returning a variable from 2
function by reference with an example. Explain about function overloading with an example. [244]
3. How do you dynamically allocate objects and object arraysin C++? Explain about constant
member function and constant object with an example, Write a meaningful program toilustrate
the use of copy constructor and destructor.
fas4s5) |
4, List the operators that cannot be overloaded in C++. Explain about explicit constructor with an
‘example. Write a program having a class to represent money. The class should have two integer -
members to:represent rupees and. paisa. Overload + and — operators for adding and subtracting *s
the objects. Then, overload, <;== and '= operators for comparing the objects. [143+6}. 5
5. What do youunderstand by protected access specifier? Explain about the different forms of a
inheritance: Define a class named Course.Derive three classes from this class named: 8
Mathematics, Science and Engineering. Then, derive two classes from Science named: Physics
‘and Chemistry. Define data members and member functions as appropriate. llustrate the
concept of member function overriding and accessing overridden member from the derived
lass in your program, [1+346}:
6. List any four formatting flags of los class with their usage. Explain with an example how a non- -
parameterized user-defined manipulator can be defined. Write a program for managing a simple
library database. The information to be stored in the database are book id, book name, *
borrower's id, borrower's name, issue date and due date. Your program should have features to
add a record, display all the records and display a set of records corresponding to a particular
borréwer’s id or a particular borrower's name.
7. What are pure virtual function and abstract class? How is dynamic_cast used? Write a
‘meaningful program to illustrate overloading of a function template with both a normal function
and a function template.
8. What are class templates? What do you understand by rethrowing an exception and catching all
the exception? Define a class to represent time. It should have a member function to read time
from the user and a member function to display the time. The function to read time must raise
‘an exception ifthe user enters invalid values for hours, minutes or seconds. The exception
thrown should contain arguments. The exception should be handled outside of the member
function of the class. [a4e5}
&
ane : S23° TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
Examination Control Division
| Programme |
2069 Chaitra { Year / Part
Y Candidates are required to give their answers in their own words as far as practicable.
Y Attempt All questions.
Y The figures in the margin indicate Full Marks.
¥ Assume suitable data if necessary.
1. What are the characteristics of OOP? How does the OOP differ from PoP?
Using object oriented technique, write a program to create aclass vector
that reads integer number, Perform vector addition by passing object as
e 128
armument and returns the object a result. A vector Is a lass with array a5 oe
2. What is the significance of using inline function? Describe with suitable
example. What do you mean by default argument? How can you relate
default argument with function overloading? Deseribe with suitable
example. _
4. Define constructor and destructor. Write down different types of
Constructors with syntax. Create a class mdistance to store the values in
Conrer and centimeter and class. edistance to store values.in feet and inches.
Perform addition of object of mdistance and object of edistance by using
friend function, (242461
4. Why do we need operator overloading? How can you overload operators
ein member function and nonmember function? Write a program to overload
felational operators (=, !=, >, <,>=, <=) to compare complex numbers. 124345)
5, How do different types of derivation affect the members of class? Write
down the types of inheritance. What kind of problem is encountered in
snultipath inheritance? Write down its solution with suitable example, (24242 +47
6. Write down the different techniques for formatting /O stream with
example. Explain the different errors encountered during file operation. 15451
7. Explain the need of virtual function with suitable example. What do you
mean by run -time type information (RTTI)? How dynamic cast and
typeid operators are used to achieve RTTI? [54243]
8. Define class template and function template with respective syntax, What
are the different exception handling techniques in C++? Explain with
appropriate example. (542431
eer23 TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING Leve ‘BEL
Examination Control Division | programme
2070 Ashad (Year:
Full Marks 80
Pass Marks | 32
Object Oiened Programming 0)
ites are required to give their answers in their own words as far as practicable.
Y Attempt All questions.
¥ The figures in the margin indicate Full Marks,
¥ Assume suitable data if necessary.
1. Write down the limitations of procedural programming. Compare procedural and object
oriented programming. Write program to find prime number in procedural and object
oriented ways. [24246]
2. What do you understand by friend functions and classes? Explain with example, Write a
program to add members of objects of two different classes.
(446)
3. What do you mean by namespace? Explain how namespace can be used. Write a program
that uses pass by reference to change meter to centimeter using pass by reference along
with the namespace. (2+2+6)
4, Explain the binary and unary operator overloading along with their syntax and example.
Write a program to add two matrices by overloading the + operator.
[4+6
Explain the constructor and destructor invocation order in single and multip!
‘Also show how a parameterized base class constructor is called when derived class object
are created. Write a program to create classes to represent student, teaching staffs and non-
teaching staffs from the base class person. Use proper members in the classes to make your
program meaningful. [46
What'do you mean by manipulators? Explain different manipulators available in C++.
Write a program that stores information of a students in a file and display the file's content
in descending order according to their marks obtained. [14346]
7. What are virtual functions and pure virtual functions? Explain abstract class and its use.
Write a program having student as an abstract class and create derived class such as
Engineering, Science and Medical. Show the use of virtual functions in this program. [24246]
8, What do you understand by function template? Write down the syntax and use of function
template. Write a program that will find the sum and average of elements in an array using (54246)
function templates.
sae23 ‘TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
(Wear/ Part
“Subject: - Object Oriented Programming (CT 501) _
Candidates are required to give their answers in their own words as far as practicable... -
Attempt All questions. :
The figures in the margin indicate Full Marks,
Assume suitable data f necessary
KARA
_ 1. What is éncapsulatidn? ‘What rt its advantages? How can encapéulation be enforced i=
C++? Write a program to create a class LandMeasure that reads Ropani, Ana, Paisa atid.
Dam as data members., Write a function’ 16 pass two objects of type Land Measure’and
return their sum. (16 Ana= 1 ee 4 Paisa = 1! Ana, 4.Dam = 1 Paisa) [1+14246]
2. What is function overtobatn ing? Use. new’ nd diel operators to ‘store -mumbers
dynamically and find their average using casting operator. What are the things we should
remember while using default argument. Explain with an example. [24543] :
‘What do you mean by friend function and friénd class? Do fiiends vidlate encapsulation?
‘Write a program that can store Department ID'and Department name with constructor. >,
Als6' write destructor in the same class and show that objects are destroyed in reverse
order of creation with suitable message, [24345]
4, List'the’ operators which cansiot be’ overloaded. Why does the overloading of binary
operator with member function requires otily ‘one argument? Create a class having an
‘array as’ member. Overload index operator ({ }) to input and display the elements in the
‘artay. . S [24246] ©
“8. Ho do you adces$ overridden members of the basé class from » member function int 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, 24345]
6... What are the primary trade ‘offs between static and dynaniie sitting? What i8 pure virtual
+ funtion? Write’s function template for the fusistion power( ) which has two patanieters
‘base arid exp and returns base". The type Of base is. the parameter to the template-and’,
exp is int. Ifthe exp is negative, thei it must be converted to its positive equivalent For
example 2” and 2? must both rebum 8. te} |
7. Whit is file wie Write a class student with roll, name, address, marks'os 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'programi to search a specific tetord of
student using roll number as key from user input,
are, the advantages of Exception ‘Heindling over Conventional Enror Handling
shanism? Explain the constructs for Exception’ Handling in C++ with.an example.
(© Write'a meaningful program illustrating the use of both Exception with argument and
Exception Specification for function. [3134]
se
fae)[Maan] Ragas Bac
Level BE Fall Warks
Programme
Wear Part
Pass Marks.
Bu
At Candidutis are requis
i 2x alenpt AY gtteationtges
Phe Rgures ia. she-margin tadiea
Yo asusne Sullald abate Ff necessar
mpere Cand Ck, Write dowa digverent feutitmes of Crt
2) Wat do yeu nderstand by the stile data member and nem
++ "use in-the programe. -Weite.a program thit uses'sialie member
suvinsher 2
er functions? Exploin the
¢r functions ‘and-slatic, data.
: [2986]
| 4y What 0. you midersidnd by default argunienis? Replice “the fimetion’ with, default
argument with function “overloading: ‘Write a -prograin to find the area of triangle. (when
hiee sides ace given) endvarea of rectangle using function overldading nd default...
AST argimeat., mg ey agg ak doh? AROS]
4, What ere\the overloadable operators. in Cai ‘Write down the: syntéx for operator
{Overloading if different cases, Write Program. to compere the mnagnitide.of complex
= operalers : [24246]
tplall Gite types, of ngcess -apectiiers aise in inheitaive Explain the case of |
ambiguity. in itheritance. ‘Write a program that shows ambiguity in multiple:inheritance, 24246],
What do you mean by stream? Explain different stream class for file input/oulpu. Write a »
| 2 dregan be Simi the output in pyramid hem as llovs Doe BS Rag]
oven mesh by polymorpbio class? What are different RTT mechanisms ini C449.
gram that'shows both RT'TI mechanisms.“ : . [24246]
{you iriéati by teraplates? Write down the syntax: for fiaetion’ ‘template and.class
plat salVite 2 program with a clase template’ to represent atray and edd. member
VOLES $b fied yeeccimum| minimum and sor! the peneric array. 2 [24246]
Ss
[5]
15}. "|
441]
[1+6)