GTU Computer Engineering (Semester 4)
Object Oriented Programming with C++
June 2015
Total marks: --
Total time: --
INSTRUCTIONS
(1) Assume appropriate data and state your reasons
(2) Marks are given to the right of every question
(3) Draw neat diagrams wherever necessary


1 (a) (i) Describe any two characteristics of OOP.
4 M
1 (a) (ii) List benefits of OOP.
3 M
1 (b) (i) Explain>> and << operators.
4 M
1 (b) (ii) Explain how to allocate and de-allocate memory dynamically.
3 M

2 (a) 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 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.
7 M
Answer any one question from Q2 (b) & Q2 (c)
2 (b) (i) Explain merits and demerits of inline functions.
4 M
2 (b) (ii) Explain friend function with the help of an example.
3 M
2 (c) (i) Explain reference variables.
4 M
2 (c) (ii) Explain friend function with the help of an example.
3 M

Answer any two question from Q3 (a), (b) & Q3 (c), (d)
3 (a) Declare a class called logic_gate to represent logic gates. The class has three data members - input1, input2 and input3 to represent three inputs to the logic gate. The class also has a virtual function member called get_gate_output. Derive two classes from the base class logic_gate, namely, and_gate and or_gate to represent "logical and gate" and "logical or gate" respectively. Define function get_gate_output in both of these classes to get the output of the gate. Show use of above classes and functions to demonstrate dynamic polymorphism in function main.
7 M
3 (b) (i) Describe multi-level and multiple inheritances.
4 M
3 (b) (ii) Explain two usage of keyword virtual.
3 M
3 (c) Declare a class called item having data members item_code, item_name, cost and discount. Derive two classes from class item, namely employee and customer. The class employee has data members like employee_code, employee_name and amount. The class customer has data members like customer_name and amount.
Define following 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 to show usage of above functions.
7 M
3 (d) (i) Explain keywords protected and public.
4 M
3 (d) (ii) Explain needs and usage of this pointer.
3 M

Answer any two question from Q4 (a), (b) & Q4 (c), (b)
4 (a) Declare a class called bird having private data members name and weight. Define following functions :
- default constructor for 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 bird object is less than that of the second & true otherwise. Define main to illustrate use of above functions.
7 M
4 (b) (i) s assignment operator overloaded by default? Justify your answer. When do you overload it mandatorily?
4 M
4 (b) (ii) Explain various constructors of ofstream.
3 M
4 (c) (i) Declare a class called book having members like book_title, publisher and author_name. Overload extractor and inserter operators ( >> and << ) for class book.
4 M
4 (c) (ii) Explain manipulators.
3 M
4 (d) (i) Explain copy constructor and its use by giving an example.
4 M
4 (d) (ii) Explain flags ios::binary and ios::ate.
3 M

Answer any two question from Q5(a), (b) & Q5 (c), (d)
5 (a) Declare a 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.
7 M
5 (b) By giving an example, illustrate use and working of nested try blocks and re- throwing of an exception.
7 M
5 (c) (i) Explain try, catch and throw. Give one simple example.
4 M
5 (c) (ii) Explain tellg and seekp functions.
3 M
5 (d) Write a program that opens two text files for reading data. It creates a third file that contains the text of first file and then that of second file (text of second file to be appended after text of the first file, to produce the third file).
7 M



More question papers from Object Oriented Programming with C++
SPONSORED ADVERTISEMENTS