Code: AC11 / AT22                                     Subject: OBJECT ORIENTED PROGRAMMING

Flowchart: Alternate Process: DECEMBER 2007
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.       What will be the output of following program?

#include<iostream.h>

void main()

{

float x;

x=(float)9/2;

cout<<x;

}                                                          

 

                   (A)  4.5                                               (B)  4.0

(C)    4                                                 (D)  5                                                                  

 

b.      A white space is :

                                                                                                                              

                   (A)  blank space                                  (B)  new line

(C)  tab                                               (D)  all of the above                                             

 

             c.   The following can be declared as friend in a class

                  

(A)    an object                                      (B)  a class

(C)  a public data member                   (D) a private data member

 

             d.   What would be the output of the following?

                   #include<iostream.h>

                   void main()

                   {

                   char *ptr=“abcd”

                   char ch;

                   ch = ++*ptr++;

                   cout<<ch;

                   }

 

(A)    a                                                 (B)  b

(C)  c                                                 (D)  d

                                                         

             e.   A copy constructor takes

 

(A)     no argument                                 (B)  one argument

(C)  two arguments                              (D)  arbitrary no. of arguments

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

 

(A)  no argument                                 (B)  one argument

(C)  two arguments                              (D)  three arguments

 

             g.   Which of the following ways are legal to access a class data member using this pointer?

 

(A)      this.x                                           (B)  *this.x

(C)  *(this.x)                                        (D)  (*this).x

 

             h.   If we store the address of a derived class object into a variable whose type is a pointer to the base class, then the object, when accessed using this pointer.

 

(A)    continues to act like a derived class object.    

(B)    Continues to act like a derived class object if virtual functions are called.

(C)    Acts like a base class object.       

(D)    Acts like a base class, if virtual functions are called.

 

             i.    Which of the following declarations are illegal?

                                      

(A)   void *ptr;                                     (B)  char *str = “hello”;

(C) char str = “hello”;                          (D) const *int p1;

       

             j.    What will be the result of the expression 13 & 25?

 

(A)    38                                                (B)  25

(C)  9                                                  (D)  12

 

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   What are the shortcomings of procedure oriented approach?                              (8)

                  

             b.   What is the output of following programs:                                                           (8)

                   (i)        #include<iostream.h>

int global = 10;

void func(int & x, int y)

{

x = x – y;

y = x * 10;

cout<<x<<“\t”<< y<< “\n”;

}

void main()

{

int global = 7;

func(::global, global);

cout<<global<<“\t”<<::global<<“\n”;

func(global,::global);

cout<<global<<“\t”<<::global<<“\n”;

}

 

                   (ii)       #include<iostream.h>

void main( )

{

int i, j, m;

int a[5]={8, 10, 1, 14, 16}

i = ++a[2];

m = a[i++];

cout <<i<<m;

}

 

  Q.3     a.   Illustrate the concept of function overloading with the help of an example. Also explain how is matching done in case of overloaded function?            (6)

 

             b.   Define a class Coord having two members type int as x and y. Use this class to define another class Rectangle which has two members of type Coord as UpperLeftCoord and BottomRightCoord. Define the constructors and member functions to get the length and breadth of rectangle. Write a global function which creates an instance of the class Rectangle and computes the area using the member functions.          (10)

                  

  Q.4     a.   Why is destructor function required in class? What are the special characteristics of destructors? Can a destructor accept arguments?               (8)

 

             b.   What is meant by a constant member function? How is it declared? Give an example.                     (8)

 

  Q.5     a.   Write a program to convert the polar co-ordinates into rectangular coordinates. (hint: polar co-ordinates(radius, angle) and rectangular co-ordinates(x,y) where x = r*cos(angle) and y = r*sin(angle)).                                                             (8)

            

             b.   What is a function template? Write a function template to find a maximum value from an array.                                                                   (8)

 

  Q.6     a.   What are the basic differences between manipulators and ios member functions in Implementation? Give examples.                                            (8)

         

             b.   Write a program that shows the use of read() and write() to handle file I/O involving objects.                                                                      (8)

 

  Q.7           Explain the following:

                   (i)   Non public constructors

                   (ii)  Inline function

                    (iii) Virtual functions

(iv) Types of Inheritance.                                                                         (4x4=16)

                                                                                                                                                

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

 

             b.   When do we use multi catch handlers? Explain with an example.                         (8)

                  

  Q.9     a.   When does ambiguity arise in multiple inheritance? How can one resolve it? Develop a program in C++ to create a derived class having following items: name, age, rollno, marks, empcode and designation.

                   Design a base class student having data members as rollno, marks and the another base class is employee having data members as empcode and designation. These both base classes are inherited from a single base class person with data members name and age. The program should carry out the required input( ) and output( ) member functions for all.        (12)

 

             b.   Class Y has been derived from class X. The class Y does not contain any data members of its own. Does the class Y require constructor. If yes, why?                                                                       (4)