PROMOTE MY BLOG: JUST CLICK BELOW BUTTON

Search Any Paper On This Blog

Saturday, July 23, 2011

CS304 Solved FinalTerm Subjective



Question No: 31    ( Marks: 1 )
 Is Deque a Birectional Container?

Yes, deque behaves like queue (line) such that we can add elements on both sides of it.

   
Question No: 32    ( Marks: 1 )
 What is meant by Generic Programming?

Generic programming refers to programs containing generic abstractions general  code that is same in logic for all data types like printArray function), then we instantiate that generic program abstraction (function, class) for a particular data type, such abstractions can work with many different types of data.
   
Question No: 33    ( Marks: 2 )
 Sort the following data in the order in which compiler searches a function?
Complete Specialization, Generic Template, Partial Specialization, Ordinary Function.

Specializations of this function template, instantiations with specific types, can be called just like an ordinary function:
cout << max(3, 7);   // outputs 7
The compiler examines the arguments used to call max and determines that this is a call to max(int, int). It then instantiates a version of the function where the parameterizing type T is int, making the equivalent of the following function:
int max(int x, int y)
{
    return x < y ? y : x;
}
 
the C++ Standard Template Library contains the function template max(x, y) which creates functions that return either x or y, whichever is larger. max() could be defined like this:
template <typename T>
T max(T x, T y) 
{
    return x < y ? y : x;
}

 
Question No: 34    ( Marks: 2 )
 State any conflict that may rise due to multiple inheritance?
The conflict may arise is the diamond problem, which our author likes to call the “diamond of doom”. This occurs when a class multiply inherits from two classes which each inherit from a single base class. This leads to a diamond shaped inheritance pattern.
For example, consider the following set of classes:
classPoweredDevice
{
};
classScanner: publicPoweredDevice
{
};
classPrinter: publicPoweredDevice
{
};
classCopier: publicScanner, publicPrinter
{
};

Scanners and printers are both powered devices, so they derived from PoweredDevice. However, a copy machine incorporates the functionality of both Scanners and Printers.
Ambiguity also cause problem.


   
Question No: 35    ( Marks: 3 )
 Describe three properties necessary for a container to implement Generic Algorithms.

If you declare a container as holding pointers, you are responsible for managing the memory for the objects pointed to. The container classes will not automatically free memory for these objects when an item is erased from the container.
Container classes are expected to implement methods to do the following:
·        create a new empty container (constructor),
·        report the number of objects it stores (size),
·        delete all the objects in the container (clear),
·        insert new objects into the container,
·        remove objects from it,
·        provide access to the stored objects.


   
Question No: 36    ( Marks: 3 )
 Write three important features of virtual functions.
With virtual functions, derived classes can provide new implementations of functions from their base classes. When someone calls a virtual function of an object of the derived class, this new implementation is called, even if the caller uses a pointer to the base class, and doesn't even know about the particular derived class.
The virtual function is an option, and the language defaults to non virtual, which is the fastest configuration.
The derived class can completely "override" the implementation or "augment" it (by explicitly calling the base class implementation in addition to the new things it does).

Question No: 27      ( Marks: 2 )
 

Describe the way to declare a template function as a friend of any class.

Template templatename
Class calssname
{
Friend void friend templatename (classname <templatename> astric const prt classname);
}



Question No: 28      ( Marks: 2 )
 

State any two reasons why the virtual methods can not be static?

1-virtual method can not be static as it is dynamic
2-as virtual method is dynamic so it works automatically that is also another reason
That virtual method can not be static.


Question No: 29      ( Marks: 2 )
 

Explain the statement below,
vector<int> ivec(4, 3);




Question No: 30      ( Marks: 2 )
 

Explain two benefits of setter functions.

1-      It minimize the changes to move the objects in inconsistent states
2-      You can write checks in your setter functions to check the validity of data entered by the user, for example age functions to check to calculate the age from date entered.


Question No: 31      ( Marks: 3 )
 

Consider the code below,

template< typename T >
class T1 {
    public:
    T i;
    protected:
    T j;
    private:
    T k;
    friend void Test();
    };
   
This code has a template class T1 with three members i,j and k and a friend function Test(), you have to describe which member/s of T1 will be available in function Test().


public:
    T i;
    protected:
    T j;



Question No: 32      ( Marks: 3 )
 

What do you mean by Stack unwinding?
When we want to check what happens actually to the local variables in the try block when then an exception is thrown this concept is called stack unwinding.



Question No: 33      ( Marks: 3 )
 

Give the c++ code of case sensitive comparison function of string class.




Question No: 34      ( Marks: 5 )
 

What is random_iterator? What is relation between random_iterator and Vector?

Random_iterator: it provided both increment and decrement and also provide constant time methods for moving forward and backword in arbitrary sized steps. Ramdom iterator provide asentially all of the operations of ordinary c pointer arithmetic.

Vector class provide an stl style random access iterator for use with generic algorithm since neither the vactor nor the matrix classes are container classes in actuall. The iterator class is really an iterator of data object that is  viewed by vector or matrix.




Question No: 35      ( Marks: 5 )
 

What would be the output of this code?

class mother {
  public:
    mother ()
      { cout << "mother: no parameters\n"; }
    mother (int a)
      { cout << "mother: int parameter\n"; }
};

class daughter : public mother {
  public:
    daughter (int a)
      { cout << "daughter: int parameter\n\n"; }
};

class son : public mother {
  public:
    son (int a) : mother (a)
      { cout << "son: int parameter\n\n"; }
};

int main () {
  daughter rabia (0);
  son salman(0);
 
  return 0;
}

Output will be

Mother
Daughter: rabia
Son: salman

By : ADEEL ABBAS 
www.allvupastpapers.blogspot.com 
AdeelAbbasbk@gmail.com

No comments:

Post a Comment

PLEASE COMMENT ABOUT YOUR VISIT AND MY SITE

Note: Only a member of this blog may post a comment.