Cochin University Exam Papers BE CS 3rd Semester
Object Oriented Programming Using C++ Nov 2010
IT/CS 304 Object Oriented Programming Using C++
(Answer ALL questions’)
I. (a) Differentiate class and object in Object Oriented Programming.
(b) List five benefits of Object Oriented Programming.
(c) Explain function overloading with an example.
(d) How do we declare and use array of pointers?
(e) What are the four tasks performed during exception handling? What are the keywords used for it?
(f) We use colon (I) operator for various purposes. Explain each one with a small example.
(g) Explain with examples the string functions insert () and replace ( ).
(h)Draw block diagram for five types of inheritance.
2. (a) Draw the flow charts for ‘while’ loop and ‘for’ loop. How can we implement ‘for’ loop using ‘while’ loop?
(b) What will be the value of X and y after execution of the following codes? Justify you answer.
(i) intx = l, y = 0;
y = x + +;
(i) int x = 5
int>, = jc + + * ++x
III. (a) Distinguish between function declaration, definition and call with suitable example.
(b) We provide ‘return O;’ as the last statement of main. What does it indicate?
(c) What is abstraction? How is it useful in Object Oriented Programming?
IV. (a) How do we invoke a constructor function? Give examples.
(b) Define a class ‘string’ as a user-defined data type with 2 constructors – to create uninitialized string object and to create objects with string constants.
(c) Show how we can declare, define and invoke a friend function with a sample code. What is the advantage of friend function?
V. Write short notes on :
(i) Static member variables
(ii) Copy instructor
(ii) Dynamic construction.
(Give appropriate examples)
VI. (a) Write a code template for the following inheritance structure.
(b) Write a program to declare a void pointer and three variables – int, float and char. Use the pointer to assign values to these three variables and display them using ‘count’.
VII. (a)Create a base class ‘shape’ with three double type data members and three member functions – get data (), display () and area (). Make area () as a virtual function.
(b) Derive three classes rectangle, triangle and circle and redefine the function area () accordingly. Write a menu driven program that will read the dimensions of a triangle, rectangle and circle and display their area.
VIII. Write a C++ program to read characters from an existing text file (say text 1); remove the digits (0-9), if any from the contents and store the contents in another file (say text 2). (15)
IX. Write the general format for class template and function template. What is the difference between them?
‘Seekg ( )’ moves get pointer to a specified location. Let‘file’be the stream object. Write function calls to move get pointer to
(i) Start position
(ii) End of file
(iii) Backward ‘ u’ bytes from current position.
(iv) Backward ‘u’ bytes from the end.