You are on page 1of 3
B.Tech / Even Q.No.cs 404/111 (6-17)/Rep, 2016-17 OBJECT ORIENTED PROGRAMMING CS 404 Full Marks : 70 Time : 3 hours The figures in the margin indicate full marks. Answer Q. No. 1 and any four from the rest. Your answers should be brief and to the point 1. @ Justify the following statements with examples (as required) in terms of object oriented programming in (Cia (@) Object-oriented programming paradigm has more control over data compared to procedure-oriented para- digm. (6) Friend functions can act as bridges among classes. (c) Bit-wise copying of objects may often be dan- gerous. (@ Input output statements in C++ are more safe, compact and user-friendly compared to C. (e) Initializing reference and constants members is tricky in C++ classes. (wi) Illustrate how the C++ compiler modifies the basic program code by decorating function names, inserting G/33-130 [ Turn Over | a) additional arguments or translating statements in follow- ing cases: operator overloading and member method argument list (6x2)+4 Define a class Date with day, month and year as data members (atleast) and methods readDate(), displayDate(), diffOfDates() as member methods. Include overloaded con- structors with suitable default arguments (Set the default date to be 1* Jan 2000). Overload the following operators <<, >>, ++ (post increment), != in a suitable way. 384+3+8 (@) Justify the statement “Templates in C++ enables a programmer to write generic classes and functions”. (6) Define a C++ template class to implement a queue abstract data type (ADT) (use dynamic allocation). Add suitable constructors (with default arguments) and destruc- tor and relevant methods. Illustrate its use by instantiat- ing a queue with characters and a queue with float ele- ments. (c) Write suitable codes fe implement such that the fol- lowing statements are supported. queue q,p; int b= x+c’,// insert the character ‘c’ into queue object x char a=-x;, // delete one character from the queue object x p=q; 2+6+6 (@) What is inheritance ? State the different types of in- heritance with examples. Gisa-130 - [ Continued ] (5.89) (0) State the features of static data, static methods and static objects in terms of their usage, initialization, access rules etc. Illustrate with example. (¢) Explain when and how virtual base class is used. * 5+5+4 5. (a) What is late binding, explain with an example ? Explain how C++ compiler implements late binding late binding. : (6) Explain the use of inline function and enumerated data type in C++ (c) Explain the use of virtualbase class. (4+4)+2+4 6. (a) Write the C++ code to dynamically allocate a 3-d array with ‘c’ columns, ‘r’ rows and ‘p’ planes using new operator. Show how to deallocate the same using delete operator. (0) Write a C++ method for a complex class to support the following (assume suitable member data): complex cl,c2,c3; cin>>c1>>c2>>c8; (c) Illustrate the use of friend function in operator over- loading. (@) Write a C++ class demoStatic which has a method to count and display the number of objects created for the class at a particular point of time. 44+3+3+4 7. Write notes (any two): ond G/33-130 [ Turn Over ] Ce) (a) Templates in C++ (0) Exception handling in C++ (©) Polymorphism in C++ (@ Object-oriented programming features and advan- tages. G/33-130

You might also like