DipIETE – ET/CS (NEW SCHEME)   –   Code: DE70 / DC56

 

Subject: OBJECT ORIENTED PROGRAMMING WITH C++

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:                                  (210)

                

             a.  When m = 36,  n = 6.  What would be the result of the evaluation of the following expression?

                                                                                                                                               m%n++

 

                  (A) 0                                                    (B) 1

                  (C) 7.2                                                 (D) None of the above

 

             b. A “structure” brings together a group of?

 

                  (A) Items of the same data type            (B) Variables

                  (C) Related data items                          (D) Integers with user defined names

 

             c.  Which of these is correct to define a pointer?

 

                  (A) int  *ptr ;                                        (B) int_ptr x ;

                  (C) *int  ptr ;                                        (D) *x ;

 

             d.  What is “num [4]” in these two expressions?

                  (i)  int num[4] ;                                      (ii)  num[4] = 5 ;

 

 

                  (A)  First is particular element, second is type                                                                    

                  (B)  First is size, second is particular element

                  (C)  First is particular element, second is array size                                                            

                  (D)  Both specify array elements

 

             e.  Which of these is a type of Inheritance?

 

                  (A) Public                                             (B) Private

                  (C) Protected                                       (D) All of the above

 

             f.   Which of the following contains overloaded insertion operator?

                 

                  (A) ostream                                          (B) iostream

                  (C) fstream                                           (D) bufferstream

 

             g.   The function’s most important role is to

 

                  (A) Give a name to a block                  

                  (B) Reduce program size

                  (C) Accept arguments and provide a return value                                                              

                  (D) Organize a program into conceptual units

             h.  Which of the following operators can be overloaded?

                                                                                                                                                                       

(A)  Array index [ ]                                (B) Addition +

                  (C) Subtraction -                                  (D) All the above

 

             i.   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.

                       

             j.   A process of a class can contain object of another class is called

 

                  (A) Nesting                                          (B) Friend

                  (C) Data Abstraction                            (D) Encapsulation                                                 

            

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

 

  Q.2     a.   What is Object Oriented Programming? What are its salient features?                 (6)

                  

             b.   What is a logical operator? Give the list with description?                                    (4)

       

             c.   What would be the output of the following program:

                        //Program to demonstrate arithmetic operators

#include<iostream.h>

#include<conio.h>

void main()

{

int x=3, y=7, r=2, s=15;

float n=3.5, p=0.5;

cout<<"\n";

cout<<x+n/p-(y*r)/s;

cout<<"\n";

cout<<(s-y/x)+n+p*r;

cout<<"\n";

cout<<p+n*s-r*s/x;

cout<<"\n";

cout<<s%x;

cout<<"\n";

cout<<s++;

cout<<"\n";

cout<<--y;

getch();

return;

                       }                                                                                                                   (6)

 

  Q.3     a.   Describe using classes to create objects by point declaration?                             (3)

            

             b.   What is a Dynamic Object? How dynamic objects are created using ‘new’? How these are deleted?                                                                     (3)

 

             c.   What is a Member Function? How it is declared?                                               (3)

 

             d.   Write a program in C++ to calculate wages, with a class Supervisor, having the following private members:

                                    sname                          20 characters

                        hrswkd                          float  

                                    wagerate                       float         

                                    totalwage                      float

                                    calcwage                      function with float return type to calculate

                                                                         total wages = hrswkd * wagerate

                   Public members of the class Supervisor are:

                   Input_Data ( )               a function to read sname, hrswkd, wagerate and

                                                         invoke calcwage (), to calculate totalwage                        

                   Output_Details             a function to print all input data & totalwage                    (7)

                  

  Q.4     a.   What is operator overloading? Enumerate the process by means of an illustrative code, to overload operator ‘+’, to add two complex numbers.       (5)

       

             b.   Which operators cannot be overloaded?                                                             (2)

 

             c.   Write a program in C++ to read two integer numbers ( x  positive and y negative), and one float point number z, and use overloaded ‘operator minus’, to change the sign of each number, and print the results?                                                           (6)

 

             d.   Write short notes on Destructors? Illustrate with an example?                              (3)              

  Q.5     a.   What are the types of the inheritance? Give their brief description.                       (8)

 

             b.   Study the following part program, and answer the questions given below:

                                    //Part program

                                    class Orgsn

                                    {

                                    int A;

                                    protected :

                                    int B, C ;

                                    public:

                                    void INPUT (int);

                                    void OUTPUT ( );

                                    };

                                    class Dept : protected Orgsn

                                    {

                                    int X, Y;

                                    protected :

                                    void IN (int, int);

                                    public:

                                    void OUT ( );

                                    };

                                    class Officer : public Dept

                                    {

                                    int P;

                                    void DISPLAY(void );

                                    public:

                                    void ENTER ( );

                                    };                                      

                   (i)  Name the base class.

                   (ii) Which is the derived class of class Dept?

                   (iii) What are the data members which can be accessed from function OUT( )?

                   (iv)  Name the private member function(s) of class Officer.                                  (8)          

  Q.6     a.   What are the types of the polymorphism?                                                           (5)

 

             b.   What are the blocks used in Exception Handling? Give a general syntax.             (5)

 

             c.   Write a program in C++ using Function Overloading, to multiply:

                   (i)  Two integer numbers                      (ii)  Two floating point numbers

                   Use the same function for multiplication. Print input numbers and the results.                                    (6)                                                                  

Q.7    a.    Why there is a need for templates? Mention types of the templates.                     (6)

 

             b.   Write a program in C++ using templates, to exchange:

                   (i)   Two numbers ( Set1: 15, 20 and Set2:  10.5, 23.3)

                   (ii)  Two single characters ( P, Q)                                                                     (10)

 

  Q.8     a.   What is I/O System of C++? What is a Stream; explain with examples?  What is Pre-Defined Stream; explain with examples?                         (5)

 

             b.   Give the syntax for opening a new file for writing, or opening an existing file for writing, without  destroying its contents?                                             (3)

 

             c.   Write a program in C++ for creating a new file MyDA.txt.  Open the file and add the following DA details:

                                    DA For April:            Rs.5000

                                    DA For May:            Rs.5500

                                    DA For June:             Rs.6000

                                                     DA For July:                                                            Rs.6000

                   Then open the file for reading, and close it after reading.                                      (8)

 

Q.9             a.                                                        How the elements of a single dimensional Array are represented? How the single dimensional Array is stored using Row major technique?              (5)

 

             b.   What is a Pointer? Why Pointers are used?                                                         (3)

 

             c.   Write a program in C++ to sort out elements of an array in an ascending (numbers increasing in value) order. The size of the array should be 2 to 20 elements.                                                                (8)