Object Oriented Programming with C++ - Dec 2014
Computer Science Engg. (Semester 3)
TOTAL MARKS: 100
TOTAL TIME: 3 HOURS (1) Question 1 is compulsory.
(2) Attempt any four from the remaining questions.
(3) Assume data wherever required.
(4) Figures to the right indicate full marks. 1(a) Explain the terms encapsulation,Polymorphism and inheritance in object oriented programming.(6 marks) 1(b) Explain the different types of argument passing techniques,with example.(6 marks) 1(c) What is function overloading?Write a C++ program to define three overloaded functions area() find area of rectangle,area of rectangular box and area of circle(8 marks) 2(a) What is a constructor? How is a constructor different form member function? Illustrate with an example.(6 marks) 2(b) What are static data members? Explain with an example? What is the use of static data members?(6 marks) 2(c) Write a class 'rectangle'containing two data items 'length' and 'breadth' and for functions setdata(), getdata(),displaydata() and area() to set the length and breadth,to get user inputs, to display and to find the area of the rectangle respectively.Also write a main program which declares the objects and uses the member functions of the class.(8 marks) 3(a) Define friend functions?Explain what the rules to be used while using a friend function?illustrate with an example.(10 marks) 3(b) 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.<="" a="">
</and<<operators>(10 marks) 4(a) Explain and write a C++ program,the process when the class is derived by the following visibility modes : i) public ii) private iii) protected(10 marks) 4(b) What is inheritance? Explain different types of inheritance.Explain the inheriting multiple base classes with an example.(10 marks) 5(a) Explain with an example,the order of invocation of constructors and destructors and passing arguments to base class constructors in multilevel inheritance.(10 marks) 5(b) What are the ambiguities that arise in multiple inheritance? How to overcomes this? Explain with example.(10 marks) 6(a) What are virtual functions? What is the need of virtual functions? How is early binding different form late biding?(6 marks) 6(b) How to inherit a virtual attribute? Explain with example.(6 marks) 6(c) What is pure virtual function? Write a C++ program to create a class called NUMBER with an integer data form member and member function to set value for this data member.Derive three classes form this base class called HEXADECIMAL, DECIMAL and OCTAL. Include a member function DISPLAY() in all these three derived classes to display the value of base class data member in hexadecimal,decimal and octal respectively.Use the concept of pure virtual function.(8 marks) 7(a) Define the concept of IO stream provided in C++. Explain in detail IO stream class hierarchy.(6 marks) 7(b) Write a C++ program to define a class called phonebook with data members name, area code,prefix and number and member functions readdata() which reads the values of the data members form the keyboard and writedata() which displays the values of data members.Enter the data for at least five phone numbers and store details in binary file phone and read the stored details and display on the screen.(8 marks) 7(c) Explain the following member functions: setf(), unsetf() and fill (),(6 marks) 8(a) What is exception handling? Write a C++ program to demonstrate the try"(10 marks) 8(b) Explain the following with respect to STL :
ii) Types of containers