AMIETE – CS/IT (OLD SCHEME)

 

Code: AC11 / AT22                                     Subject: OBJECT ORIENTED PROGRAMMING

Flowchart: Alternate Process: DECEMBER 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.       A constructor cannot be declared _______.

 

(A)    Private                                             (B)  public

        (C)  virtual                                               (D)  protected

 

b.  Inheritance depicts _______ relationship.

 

(A)     FOR-A                                            (B)  IS-A.   

        (C)  HAS-A.                                           (D)  composition.

 

        c.  A copy constructor takes _____ argument(s).

 

(A) no                                                     (B) one

(C) two                                                   (D) arbitrary number of

 

        d.  In C++, a new operator call allocates memory from ____ area.

 

(A)    heap                                                 (B)  stack

(C) global area                                        (D)  dynamic stack

 

        e.  Which of the following declarations are illegal?

 

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

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

 

        f.    In C++, operator += has _____ associativity.

 

        (A) left to right                                         (B) right to left

        (C) arbitrary                                            (D) depends on usage

 

        g.   In C++ class, all members are _____ by default.

 

        (A) public                                                (B)  protected

(C)   private                                              (D)  friend

 

        h.   What will be the result of the expression 13 & 27?

 

        (A)  38                                                    (B)  25

(C)  9                                                      (D)  12

 

       

 

 

        i.    Which of the following is NOT the valid class declaration header for the derived class D with base classes B1 and B2?

 

(A)  class D : public B1, public B2          

(B)  class D : class B1, class B2

        (C)  class D : public B1,  B2

        (D)  class D : B1, B2

 

        j.    In C++, a class may have ________ overloaded assignment operator(s).

 

        (A)  no or zero                                        (B)  one and only one

(C)  one or more than one                        (D) more than one

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

Q.2   a.      Object Oriented Programming has two important philosophies : data hiding and data abstraction. Explain.                                                                              (8)

 

         b.      What is the difference of C++ struct and C++ class? Is there any difference between C++ struct and C struct? Explain with suitable examples.                    (4 + 4 = 8)

 

Q.3   a.      The overloaded index operator [] returns by reference. What implications will be there if it returns by value? Comment and justify.                      (8)

                             

         b.      What is the role of an inline function? How does it differ from macro? Illustrate with examples.                                                                           (8)

 

Q.4   a.      Explain and illustrate the use of virtual base class through suitable examples.               (8)

 

         b.      What is the usage of this pointer? Can a static member function of class refer to data pointed by ‘this’?                                                                                      (2 + 2 = 4)                                    

 

         c.      What is the implication of putting a 'const' after a member function declaration e.g.

class X {

  void f() const;

                       };                                                                                                                        (4)     

        

Q.5   a.      Read from standard input an unknown number of strings. Store them in a list. Determine both the shortest and longest strings.                                (6)                                                                                              (4)

 

         b.      You are given a text file to read. Write a programme to compute the byte size of the file and store it at the end of the file. In addition, each time we encounter a newline character, store the current byte size, including the newline, at the end of the file.                                                                                                        (10)

 

Q.6   a       Explain, why we say that the C++ exception handling model is non-resumptive? Explain what happens during stack                      unwinding        (8)

 

        

 

 

         b       Define a class Stack with push and pop operations. Define a double ended queue in terms of the class stack.                                                                              (8)                                                       

                 

Q.7   a.      When should you define a member function as virtual? Illustrate through suitable example.                                                                                  (8)

 

         b.      Is it possible to provide a special behavior in one particular instance of a template while not for other instances of the template? Illustrate through suitable example(s).                                                                         (8)

 

Q.8   a.      In how many ways can type conversion (user-defined conversions) of class instances be specified? Explain with examples.                                       (8)

                 

         b.      Explain the behaviour of abstract class through proper example.                              (8)

        

Q.9            Write short notes on the following:                                      (16)

 

(i)   default argument

(ii)  private inheritance.

(iii) scope resolution operator.

(iv) function overloading.