AMIETE – CS/IT (OLD SCHEME)

 

Code: AC11 / AT22                                  Subject: OBJECT ORIENTED PROGRAMMING

Flowchart: Alternate Process: JUNE 2010Time: 3 Hours                                                                                                     Max. Marks: 100

 

 

NOTE: There are 9 Questions in all.

·       Question 1 is compulsory and carries 20 marks. Answer to Q.1 must be written in the space provided for it in the answer book supplied and nowhere else.

·       Out of the remaining EIGHT Questions answer any FIVE Questions. Each question carries 16 marks.

·       Any required data not explicitly given, may be suitably assumed and stated.

 

 

Q.1       Choose the correct or the best alternative in the following:                               (2 10)

       

a.       The dot operator (or class member access operator) connects the following two entities (reading from left to right)

 

(A)    A class member and a class object.

(B)  A class object and a class.

        (C)  A class and a member of that class.      

        (D)  A class object and a member of that class.

 

b.  __________________ is a mechanism that prevents direct access of class data from the outside world.

 

(A)    Inheritance                                      (B)  Polymorphism

        (C)  Data hiding                                     (D)  Message passing.

 

        c.  The class declaration contains ________________ destructors.

 

(A) Only one                                          (B) More than one but finite.

(C) Infinite number of constructors.      (D) None of the above.

 

        d.  A __________________ is a constructor that creates a new object using an existing object of the same class and initializes each data member of the newly created object with its corresponding data members of an existing object passed as an argument.

 

(A)    Copy constructor                            (B)  Overloaded constructor

(C) Parameterized constructor               (D)  Default constructor

 

        e.  When you overload an arithmetic assignment operator, the result

 

        (A) goes in the object to the right of the operator    

        (B) goes in the object to the left of the operator

(C) goes in the object of which the operator is a member    

(D) must be returned

 

 

        f.    Assume a class Derv that is privately derived from class Base. An object of class Derv located in  main() can access

 

        (A) public members of Base                  (B) protected members of  Base

        (C) private members of Base                 (D) private members of Derv

 

        g.   If there is a pointer, p , to objects of a base class, and it contains the address of an object of a derived class, and both classes contain a virtual member function, ding() , then the statement p -> ding(); will cause the version of  ding() in the ________________ class to be executed.

 

        (A) base                                                  (B)  derived.

(C)  abstract                                            (D)  none of the above

 

        h.   A function having an initializer = 0 in its declaration and which does-not provide any implementation is known as _______________.

 

        (A)  Constructor                                     (B)  Destructor

(C)  Virtual function                              (D)  Pure virtual function

 

        i.    To write data that contains variables of type float, to an object of type ofstream, we should use

 

(A)  The insertion operator                     (B)  seekg()

        (C)  write()                                            (D)  put()

 

        j.    The statement                                        

        f1.write( (char*)&obj1, sizeof(obj1) );

 

        (A)  writes the member functions of  obj1  to f1.    

        (B)  writes the data in obj1 to f1.

 (C) writes the member functions and the data of obj1 to f1.                      

             (D) writes the address of obj1 to f1.

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

Q.2   a.      Discuss the fundamental features of the object-oriented programming?             (6)

 

         b.      Explain, with the help of program code, the different methods of defining the member functions of the class?                                                                     (6)                                                                                (4)

 

         c.      What are the guidelines that are followed to decide whether the member function is inline or not?                                                                                    (4)

 

Q.3   a.      What do you mean by:                                                                                      (32)

 

                        (i)  default constructor.

                        (ii) parameterized constructor.

                             

         b.      Create the “Date” class which consists of data members ‘day’, ‘month’ and ‘year’. Include an appropriate constructors and a member function nextday() which increments the day by 1 and then display the date in proper format. (day/month/year). Check the validity of the date entered.    (10)                                                                                                (4)

        

Q.4   a.      Write a program to overload new and delete operators that will find the sum of the array elements?                                                                                  (10)

 

         b.      Is it possible to overload the ternary (? :) operator? Support your answer with proper reason?                                                                                             (6)       

        

Q.5   a.      Design a class to represent “account” information of an individual that includes the following members:-                                                                              (8)

 

                        Data Members

·         Name of account holder -------- String

·         Account number ---------- int

·         Type of Account --------- char

·         Balance Amount ---------- float

Member Functions

·         To assign initial values (using constructor)

·         To display the name of account holder, account number, account type and balance amount in the account.

·         To deposit an amount in the account.

·         To withdraw an amount.

      Use the above class to write an interactive program.                                                                               

 

         b.      Write a program to open a file whose name is passed as command line argument.                                                                           (8)                                                                                                      

        

Q.6   a       Explain the term Polymorphism? What are the different forms of polymorphism? Discuss them with their advantages and disadvantages.    (2+2+6)

 

         b       What are the rules that need to be kept in mind in deciding virtual functions?    (6)                             

                 

Q.7   a.      What is Inheritance? Discuss the different form of Inheritance?                      (4+6)

                                                                                               

         b.      Explain the difference between inheriting a class with public and private visibility mode?                                                                                                  (6)

        

Q.8   a.      What is Function template?                                                                                  (4)

        

  b.      Write a program that copies the content of a text file to another file (i.e., any . cpp file       to another  .cpp file). Add suitable documentation.                                           (8)

 

         c.      Write a function template for sorting a set of data items using bubble sort technique?                                                                           (4)                         

 

Q.9            Write short notes on following:                                                                    (5+5+6)

 

                  (i)   Runtime memory management                      

                  (ii)  Friend Function         

                  (iii) Exception Handling