Flowchart: Alternate Process: JUNE 2008

Code: AC11/AT22                                         Subject: OBJECT ORIENTED PROGRAMMING

Time: 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 best alternative in the following:                                         (2x10)

       

        a.                                                                  Which of the following operator can be overloaded through friend function?

(A)    ->                                                   

(B)  =

        (C)  ( )                                                   

        (D)  *    

 

b.  To access the public function fbase() in the base class, a statement in a derived class function fder() uses the statement.

(A)     fbase();                                           

(B)  fder();                                             

        (C)  base::fbase();                                   

        (D)  der::fder();

 

        c.  If a base class destructor is not virtual, then

(A) It can not have a function body.        

(B) It can not be called.

(C) It can not be called when accessed from pointer.

(D) Destructor in derived class can not be called when accessed through a pointer to the base class.

 

        d.  Maximum number of template arguments in a function template is

(A)    one                                                 

(B)  two

(C)  three                                               

(D)  many

 

        e.  In access control in a protected derivation, visibility modes will change as follows:

        (A) private, public and protected become protected

        (B) only public becomes protected.

(C) public and protected become protected.

(D) only private becomes protected.

 

        f.    Which of the following statement is valid?

        (A) We can create new C++ operators.

        (B) We can change the precedence of the C++ operators.

        (C) We can change the associativity of the C++ operators.

        (D) We can not change operator templates.

        g.   What will be the output of the following program?

#include<iostream.h>

void main()

{

 float x=5,y=2;

int result;

result=x % y;

cout<<result;

}

        (A) 1                                                       (B)  1.0

(C)   Error message                                  (D)  2.5

 

        h.   Which can be passed as an argument to a function?

        (A)  constant                                           (B)  expression

(C)  another function                                (D)  all of the above.

 

        i.    Member functions, when defined within the class specification:

(A)  are always inline.                             

(B)  are not inline.

        (C)  are inline by default, unless they are too big or too complicated.

        (D)  are not inline by default.

 

        j.    Declaration of a pointer reserves memory space

        (A)  for the object.

(B)  for the pointer.

(C)  both for the object and the pointer.

(D)  none of these.

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

 

Q.2.  a.      What is Object Oriented Programming (OOP)?  What are the advantages of Object Oriented Programming?                                                                              (6)

 

         b.      Write two advantages of using include compiler directive.    (4)

 

         c.      Find errors in the following code:                                                                              (6)

           #include<iostream.h>

           class A { int a1;

                     public: int a2;

                     protected : int  a3;      };

           class B :public A

                     { public:

                     void  func( )

                     { int b1, b2, b3;

                              b1 = a1;

                              b2 = a2;

                              b3 = a3; } };

 

 

                     class C : A

                              { public:

                                       void f( )

                                       { int c1, c2, c3;

                                                      c1 = a1;

                                                      c2 = a2;

                                                      c3 = a3;   }   };

                     int main( )

                     { int p, q, r, i, j, k;

                              B   O1;

                              C   O2;

                              p = O1.a1;

                              q = O1.a2;

                              r = O1.a3;

                              i = O2.a1;

                              j = O2.a2;

                              k = O2.a3;

                              }

 

Q.3   a.      Consider the following specifications:                                                                        (8)

                  Structure name       data                  type                              size

                  Name                     First                 array of characters        40

                                                Mid                  array of characters        40

                                                Last                  array of characters        60

                  Phone                     Area                 array of characters        4

                                                Exch                 array of characters        4

                                                Numb               array of characters        6

 

                  Class name             data                  type

                  N_rec                    Name               Name

                                                Phone               Phone

                 

(i)       Declare structures in C++ for Name and Phone.

(ii)       Declare a class N_rec with the following members.

           1.  Define the constructor (outside the class N_rec) that gathers the information from  the user for Name and Phone.

           2.  Define the display_rec(outside the class N_rec) that shows the current values of the data members.

 

         b.      What do you mean by static class members? Explain the characteristics of  static class members with suitable examples.                                       (8)

 

Q.4   a.      Write a template function that swaps the values of two arguments passed to it.  In main( ), use the function with integers and characters.       (4)                                                                                                        (8)

 

         b.      What do you understand by copy constructor?  Briefly explain.                                 (4)

        

         c.      What is dynamic initialization of objects? Why is it needed?                                          

                  How is it accomplished in C++? Illustrate.                                                                (8)

 

Q.5   a.      What is multiple inheritance? Discuss the syntax and rules of multiple inheritance in C++. How can you pass parameters to the constructors of base classes in multiple inheritance? Explain with suitable example.              (12)

 

         b.      What is containership? How does it differ from inheritance?                                       (4)

 

Q.6   a.      What are the two methods of opening a file? Explain with examples. What is the difference between the two methods?                                           (10)

 

         b.      What are the various ways of handling exceptions? Which one is the best?  Explain.                                                                                   (6)

 

Q.7   a.      Write a program to overload Insertion and Extraction Operator.                                (8)

 

         b.      How are template functions overloaded? Explain with a suitable example.                  (8)

 

Q.8   a.      Develop a program in C++ to create a database of the following items of the derived class.

                  Name of the patient, sex, age, ward number, bed number, nature of illness, date of admission.

 

                  Design a base class consisting of data members : name of the patient, sex and age ; and another base class consisting of the data members : bed number and nature of the illness. The derived class consists of the data member ,date of admission.

 

                  Program should carry out the following methods

(i)  Add a new entry.

(ii) List the complete record.                                                                                   (10)

 

         b.      What are friend functions?  Explain there characteristics with a suitable example.                                                                                    (6)

                 

Q.9            Explain the following.                                                                                              (16)                                                                        (16)

(i)   Conversion from Class to Basic Type.

(ii)  File Pointers.

(iii) Function Prototyping.

(iv) Overload resolution.