Oops End Term 2018
Oops End Term 2018
(Write your Roll No. on the top immediately on receipt of this question paper)
Note: Attempt all questions. Make suitable assumptionswherever necessary.
Q.1 (a) Define the tern Object Oriented Programming briefly. Write a program in C++ 6
CO1 to declare a class called book details to represent details for a book, having data
members like title, author, edition, price and no of copies available. Define
following functions: constructor(s) display function to display all data
members - find books to find and display details of all books having price less
than Rs. 250 - main to create an array of book details and to show usage of
above functions.
Q.2 (a) Declare a class called bird having private data members name and weight. 6
CO2 Define following functions: -default constructor för reading data members from
key board overloaded constructor with two arguments to be used for
initialization of data members. - display function to display data members.
overloaded member operator >= to compare weight of two bird objects,
returning false if weight of first birdobject is less than that of the second &true
otherwise. Define main to illustrate use of above functions.
(b) Define the term Generic Programming. Create a generic class stack using 6
template and implement common Push and Pop operations for different data
types.
OR
Q.2' (a)' Explain the term operator overloading. Create a class coordinate containing x, y 6
CO2 and z private variables. Perform operations for incrementing, adding and
comparing object(s) by overloading ++, += and = = operators respectively.
Define necessary functions to set and display the variables.
(b)' What is the difference between class template and function template? Declare a 6
template class called exam having an array of generic type as a data member,
named elements[10]. Define following generic(template) member functions:
sort( ) to arrange elements in ascending order - find max( ) to find and return
maximum from the array. Define main to illustrate usage of these functions to
process two different types of data.
Q.3 (a) Declare a class called item having data members item code, item name, cost
CO3 and discoun. Derive two classes from class item, namely employee and
CUStomner. The class employee has data members like employee code,
emplove name and amount. The class customer has data nenbcrs Jike
customer name and amount. Define functions for - initializing data members.
-displaying the values of data members. computing amount to be paid for a
purchased item. Also define function main to create objects of both derived
classes and toshow usage of above functions
(b) What is the difference between compile time and run time polymorphism? 6
Explain the usage of virtual keyword in implementing run time polymorphism
with the help of a suitable example.
OR
Q.3' (a) What do you mean by Inheritance? What are its different types? 6
CO3 Explain the concept of virtual base class with a suitable program in Ct+.
(b)' Demonstrate how parameters are passed to base class constructors in multilevel 6
inheritance in C++, Also discuss the order of execution of constructors and
destructors.
Q.4 (a) What are main features of an abstract class in JAVA? Implement an abstract 6
C04 class called Shape which has three subclasses say Triangle, Rectangle, and
Circle. Define one method area() in the abstract class and override this area() in
these three subclasses to calculate for specific object i.e. area) of Triangle
subclass should calculate area of triangle etc. Same for Rectangle and Circle.
Which 00P feature is implemented by this program?
(b) Explain interface in JAVA. Write a program that illustrates interface inheritance. 6
Interface P is cxteisded by Pl and P2. Interface P12 inherits from both Pl and
P2.Each interface declares one constant and one method. class QÌ implements
P12.Instantiate Q and invoke each of its methods. Each method displays one of
the constants.
Q.5 (a) Discuss the mechanism of keywords try, catch and finally to handle Exceptions 6
CO5 in Java. Explain with an example like division by zero" situation? Show with
example working of Nested Try and multiple catch blocks.
(b) What do youmean by a Thread? Write a program to create multiple Threads in 6
JAVA using Runnable interface. Why synchronization is required in
multithreaded programming and how can we implement it in program?