VTU Computer Science (Semester 4)
Object Oriented Programming with C++
December 2011
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) Explain the terms encapsulation, polymorphism and inheritance in object oriented programming.
6 M
1 (b) What is function overloading? Write a C++ program to define three overloaded functions area (), to find area of rectangle area of rectangular box and area of circle.
8 M
1 (c) With an example explain the concept of inline functions.
6 M

2 (a) Differentiate between class and object. Write a C++ program to define a class called TIME with hour, minute and second as data members and read(), display() and add() as member functions.
10 M
2 (b) What is a constructor? What are its characteristics? Define a suitable parameterized constructor with default values for the class box with data members length, breadth and height as data members.
10 M

3 (a) What is a friend function? Explain the need of friend functions in C++.
5 M
3 (b) Write a C++ program to swap two integer and floating and floating-point numbers, using a function template.
5 M
3 (c) What is operator overloading? Write a C++ program to add two complex numbers by overloading the + operator. Also overload >> and << operators for reading and displaying the complex numbers.
10 M

4 (a) Explain the visibility of the base class members, for the access specifiers: private, protected and public while creating the derived classes.
6 M
4 (b) Differentiate between private member and protected members. Write a C++ program to illustrate protected members in the base class.
7 M
4 (c) With an example explain multiple in heritance.
7 M

5 (a) With an example explain the order of invocation of constructors and destructors and passing arguments to base class contractors in multilevel inheritance.
10 M
5 (b) What are the ambiguities that arise in multiple inheritance? How to overcome this? Explain with examples.
10 M

6 (a) What is a virtual function? Explain with a suitable example.
6 M
6 (b) Write a C++ program to create a base class called shape. Use this class to store two double type value that could be used to compute the area of figures. Derive two specific classes called traingle and rectangle form the base shape. Add to the base calss, a member function get_data() to initialize base class data members and another member function display_area() to compute and display the area of figures. Make display_area() as a virtual function and redefine this function in derived classes to suit their requirements.
8 M
6 (c) Write a C++ program to create base class called number with an integer data member and a member function to set the value for this data member. Derive three classes from this base class called hexadecimal, decimal and octal. Included a member function show() in all these three derive classes to display the value of the base class data member in hexadecimal, decimal and octal respectively. Use the concept of pure virtual functions.
6 M

7 (a) With an example and general syntax explain the member functions:
(i) Width()
(ii) Precision
(iii) fill()
6 M
7 (b) Write a C++ program to define a class called phonebook with data members name, area code, prefix and number and the member functions readdat() which reads the values of the data members from the keyboard and writedata() which displays the value of the data members. Enter the data for at least 5 phone numbers and store details in a binary file phone and read the stored details and display on the screen.
9 M
7 (c) Briefly explain the member functions:
setf() and unsetf()
5 M

8 (a) What is exception handling? Briefly explain the facilities in C++ for exception handling.
10 M
8 (b) Briefly explain the use of containers, vectors, lists and maps in STl.
10 M



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