Cochin University Exam Papers BE CS 3rd Semester
Object Oriented Programming Using C++ Nov 2008
IT/CS 304 Object Oriented Programming Using C++
(2006 Scheme )
(Answer All questions)
(All questions carry EQUAL marks)
a) Define Polymorphism. What are the techniques used by C++ for achieving it?
b) What is meant by data hiding? How it is achieved?
c) How inline function is defined? What are its merits and limitations?
d) How the member functions and the static variables of a class are stored in memory?
e) Compare and contrast the following declarations:
i) Char SI ii) String S2
f) How C++ manages dynamic memory?
g) What is late binding?
h) What is an exception and how they are handled?
II. a) Compare procedural programming with object oriented programming.
b) Write a class named ‘Fibonacci’ to generate first ‘n’ Fibonacci numbers. Use necessary member variables, member functions and constructor. Test this class in the main program.
III a) How data input and output is done in C++?
b) Write a program using class to find the largest and smallest of ‘n’ elements which are input into an array in the class. Use necessary member variables, member functions and constructor.
IV a) What is function overloading?
b) Write a program to find the area of a circle, rectangle and triangle (given 3 sides)
by overloading the function area.
V a) What is operator overloading?
b) Write a class named ‘Matrix’, which contain a two dimensional array, rows, columns as me*nber variables. Overload the binary operators + and *, and unary operator (to negate all values) for the matrix class. Using main program, test various operations.
VI a) What is inheritance? What are its various form?
b) Solve the problem of finding real, equal and imaginary roots of a quadratic equation ax2 + bx + c = Q,a <> 0 by implementing the following inheritance.
Class: Complex Number
real part, imaginary part
Class: Quadratic Equation
a,b,c and descriminant, roots
VII a) What is an abstract class?
b) Write a program to implement the following inheritance:
Savings Bank Account
Savings Bank Account Holder
Use necessaiy member variables for storing account holder’s personal details as well account details. In the main program, use array of objects to input details of ‘n’ savings bank account holders. Finally print a report of all ‘n’ account holders.
VIII. (a) Explain the concept of generic programming.
(b) Write a program using template class to create and manage a generic array which can store either int, float or string. Write member functions for inputting and printing array values. Using main program test the template class by creating instances with the three data types.
IX. (a) What are the three main file streams and write their import member functions?
(b)Write a program to read the contents of a text file and convert all upper case letters to lower case and vice versa and write the result into another file.