AMIETE – CS/IT (OLD SCHEME)

 

Code: AC11 / AT22                                     Subject: OBJECT ORIENTED PROGRAMMING

Flowchart: Alternate Process: JUNE 2009Time: 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.       How many destructors can a class have?

 

(A)    0                                                      (B)  1

        (C)  2                                                      (D)  None of the above

 

b.  Which of the following statements is TRUE?

 

(A)     The iostream class is a subclass of the fstream class.        

(B)  The iostream class is a subclass of both the istream class and the ostream class.

        (C)  The iostream class is a subclass of the ifstream class.        

        (D)  None of the above.

 

        c.  Which members of a base class are inherited by a subclass?

 

(A) All the public and private members.   

(B) All the protected and private members.

(C) All the public and protected members.      

(D) None of the above.

 

        d.  In C++, a function contained within a class is called

 

(A)    a member function.                           (B)  an operation.

(C) a class function.                                 (D)  a method.

 

        e.  Overloading a postfix increment operator by means of a member function takes

 

        (A) no argument.                                     (B) one argument.

(C) two argument.                                   (D) three argument.

 

 

        f.    The main( ) function returns value of type

 

        (A) real.                                                  (B) character.

        (C) int.                                                    (D) null.

 

        g.   The library function exit () causes an exit from

 

        (A) the loop in which it occurs.                 (B)  the block in which it occurs.

(C)   the function in which it occurs.           (D)  the program in which it occurs.

 

        h.   What would be the output for the following program?

 

int main( )

                                                         {

                                 int x, y=10,z=10;

                                 x=(y==z);

cout<<x;

return 0; }

        (A)  0                                                      (B)  1

(C)  10                                                    (D)  Error

 

        i.    An exception is caused by

 

(A)  a hardware problem.                       

(B)  a problem in the operating system.

        (C)  a syntax error.

        (D)  a run time error.

 

        j.    A white space is:

 

        (A)  blank space.                                     (B)  new line.

 (C)  tab.                                                  (D) all of the above.

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

Q.2   a.      Distinguish between Procedure-Oriented Programming and Object-Oriented Programming.                                                                                           (8)

 

         b.      What is the main advantage of passing arguments by reference? Explain this with an example.                                                                                                     (4)

 

         c.      Show by an example how scope resolution operator help to access global variable.                                                                                (4)

 

Q.3   a.      Write a program to overload the unary minus operator using friend function.              (8)                                                                                    (8)

                             

         b.      Explain what you understand by containership. How does it differ from Inheritance?                                                                               (4)

 

         c.      Why do we need constructors?                                                                                (4)

 

Q.4   a.      Distinguish between overloaded functions and function templates. Give example.                                                                                    (8)

 

         b.      Explain the concept of operator-overloading. Illustrate operator-overloading concept to concatenate strings.                                                                              (8)       

        

Q.5   a.      What do you mean by Virtual Base Class? Explain with an example.                         (8)                                                                          (4)

 

         b.      How is polymorphism achieved at run time? Explain with coding.                               (8)                                                                                   (10)


        

Q.6   a       Write short notes on all of the following:                                                                    (8)

 

(i)   ios class.                                                               

(ii)  setf() function.

(iii) errors during file operations.                                   

(iv) command line arguments.

 

         b       Write a program which asks for a file name from the keyboard, opens a file with that name for output reads a line from the keyboard character by character and write the line onto the file.                                   (8)                                                 

                 

Q.7   a.      Write a function template to find a maximum value from an array.                              (8)

                                                                                               

         b.      What is exception handling?                                                                                      (4)

 

         c.      Differentiate between late and early binding.                                                              (4)

 

Q.8   a.      Explain the following:

 

            (i)         Multilevel Inheritance.

            (ii)        Multiple Inheritance.

(iii)               Hybrid Inheritance.

(iv)       Hierarchical Inheritance.                                                                         (8)

                 

  b.      Define a class Date with three variables for day, month and year.

 

 (i)        Overload the operators <<, >> to read and print Date object.

(ii)        Overload > to compare two dates.                                                         (8)

        

Q.9   a.      Define the class Student which has name (char name[20]) and age(int). Define the default constructor, member functions get_data() for taking the name and age of the Student, print() for displaying the data of Student.   (5)                                                                                                                               (5)                                                                       

 

         b.      For the above defined class create an array of students of size N and write the friend function sort(Student arr[N]), which sorts the array of Students according to their age.                                                                                               (6)

 

         c.      Create a file “STUDENT.DAT” for storing the above objects in sorted order.           (5)                                                                                    (5)