OOPS with C++ - Dec 2011
Electronics & Communication (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) 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 marks) 1 (c) With an example explain the concept of inline functions.(6 marks) 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 marks) 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 marks) 3 (a) What is a friend function? Explain the need of friend functions in C++.(5 marks) 3 (b) Write a C++ program to swap two integer and floating and floating-point numbers, using a function template.(5 marks) 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 marks) 4 (a) Explain the visibility of the base class members, for the access specifiers: private, protected and public while creating the derived classes.(6 marks) 4 (b) Differentiate between private member and protected members. Write a C++ program to illustrate protected members in the base class.(7 marks) 4 (c) With an example explain multiple in heritance.(7 marks) 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 marks) 5 (b) What are the ambiguities that arise in multiple inheritance? How to overcome this? Explain with examples.(10 marks) 6 (a) What is a virtual function? Explain with a suitable example.(6 marks) 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 marks) 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 marks) 7 (a) With an example and general syntax explain the member functions:
(iii) fill()(6 marks) 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 marks) 7 (c) Briefly explain the member functions:
setf() and unsetf()(5 marks) 8 (a) What is exception handling? Briefly explain the facilities in C++ for exception handling.(10 marks) 8 (b) Briefly explain the use of containers, vectors, lists and maps in STl.(10 marks)