VTU Previous Exam Papers BE CS 4th Semester
Object Oriented Programming with C++ May/june 2010
Note: Answer any FIVE full questions, selecting at least TWO questions from each part.
1 a. Explain the various features of object oriented programming.
b. Discuss function prototyping, with an example. Also write its advantages.
c. Define the ‘this’ pointer, with an example, indicate the steps involved in referring to members of the invoking object.
2 a. What are friend non-member functions and friend member functions?
Explain with suitable examples.
b. Write a C++ program to count the number of objects of a certain class.
c. Write a note on namespaces.
3 a. What is dynamic memory management? Write a C++ program demonstrating the usage of new and delete operators for a single variable as well as for an array.
b. What are constructors and destructors? Explain the different types of constructors in C++, with examples.
4 a. Discuss with examples, the implications of driving a class from an existing class by the ‘public’ and ‘protected’ access specifiers.
b. What is function overriding? Give an example. Justify the statement: “function overriding is a form of function overloading”
c. Write a C++ program to initialize base class members through a derived class constructor.
5 a. Define and give the syntax for the following :
(i) Virtual function ; ii) Pure virtual function ; iii) Abstract base class.
b. What is a virtual table? How does it help in implementing dynamic polymorphism? Explain with an example.
c. Draw the class hierarchy for handling streams in C++. How is text input achieved in C++?
6 a. What is a stream? What are the various flags and functions associated with error handling of streams in C++?
b. What is operator overloading? Explain with examples the circumstances under which operator overloading becomes mandatory.
7 a. Create a class called ‘distance’ with data member’s feet and inches and appropriate constructor (s). Overload the greater than operator (>) for the distance class to tackle the following conditions : i) di > d2 ; ii) dj > float ; iii) Float > di, where di and d2 are objects of the distance class and float is a floating point value representing distance (ex : 4.5 means 4 feet 6 inches).
b. Create a class called ‘string’ with a data member to hold a string and a constructor to set it. Overload the subscript to set it. Overload the subscript operator for the string class to accept a character as a parameter and return the position of its first occurrence, if found, else a negative value.
c. Explain with examples, the conversion from basic type to class type and class type to basic type.
8 a. Define a function template giving its syntax. Write a C++ program to implement array representation of a stack for integers, characters and floating point numbers using class template.
b. Explain the C++style solution for handling exceptions.