Phy Assignment

Page 1

MANIPAL INSTITUTE OF TECHNOLOGY (Constituent Institute


of MANIPAL University) MANIPAL-576104 III SEMESTER B.E. (CSE) (Revised credit scheme) END SEMESTER EXAMINATION Nov/Dec - 2010 SUBJECT : OBJECT ORIENTED PROGRAMMING WITH C++(CSE-209) TIME : 3 HOUR 09 – 12 -2010 ( 9 – 12 am) MAX.MARKS : 50 Note : Answer any FIVE full questions. Missing data can be assumed. 1. a) What is a reference variable? Explain with example. b) What is an inline function? Explain with syntax. Under what conditions a function cannot become inline? c) What is dynamic memory allocation? Describe how it is achieved in C++? d) What are different types of constructors? Explain them briefly. (2+3+2+3) 2. a) What is a class? Explain with example, the components of the class. b) What is a friend function? What are the special characteristics of a friend function? c) Consider a class Student with char*name, int roll_no, float marks[5] as its private data members. Provide the following: i) a default constructor for class Student. ii) a parameterized constructor to initialize all data members of the class Student. iii) a copy constructor for the class Student.(each student has a unique roll number) iv) a member function Avg() to calculate average of five subject marks of a student and displays it. v) In main() create an array of students and initialize them appropriately. Demonstrate use of all the above functions in main() function. (2+3+5) 3. a) What is inheritance? List the different types of inheritance. b) What is a virtual function? When it is needed? c) Assume that a bank maintains two kinds of accounts for customers- savings and current. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides the cheque book but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level, a service charge is imposed. Create a class Account that stores customer name, account number and type of account. From ..... 2 Reg.No. INSPIRED BY L[FE


-2this, derive the classes cur_acc and sav_acc to make them more specific to their requirements. Include the necessary member functions in order to achieve the following tasks: i) Accept a deposit from the customer and update the balance. ii) Display the balance iii) Compute and deposit interest iv) Permit withdrawal and update balance v) Check the minimum balance, impose penalty if necessary and update the balance. Do not use any constructors. Use member functions to initialize the class members. (2+2+6) 4. a) Explain with syntax the put() and get() functions and their necessity. b) Explain with example the read() function to extract objects from input streams. How this can be achieved in case of objects holding the resource externally? c) Explain the following manipulators with example: i) setw() ii) setprecision() iii) setfill() iv) setioflags() (3+3+4) 5. a) Define operator overloading and give the syntax. Under which circumstances the operator overloading becomes mandatory. b) Explain with syntax, the overloading of ‘new’ operator for allocating memory for an array of objects. c) Define a class to represent a computer. Let the price and the brand name be the two data members. Overload the input and output operator to input a computer object and to display it respectively. Also provide the member operator methods: i) overload ‘= =’ operator to test whether two computer objects are exactly same or not. ii) overload ‘+’ operator such that the price of a computer gets incremented by a certain amount which is passed as an argument. Write a simple main() to implement the all the above methods. (2+2+6) 6. a) What is a standard template library? List the important member functions available in case of ‘list’ class (any six) and their use. b) Explain with syntax what a class template is. c) What will happen in the following situations? Explain. i) an exception is thrown outside a try block.


ii) no catch handler matches the type of exception thrown. iii) several handlers match the type of thrown exception. iv) a function throws an exception of type not specified in the list. (4+2+4) **************


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.