PROMOTE MY BLOG: JUST CLICK BELOW BUTTON

Search Any Paper On This Blog

Saturday, July 23, 2011

CS304 Unsolved Final Paper


FINALTERM  EXAMINATION
Fall 2009
CS304- Object Oriented Programming (Session - 4)
Time: 120 min
Marks: 75

  

Question No: 1    ( Marks: 1 )    - Please choose one
 A template provides a convenient way to make a family of
       variables and data members

       functions and classes

       classes and exceptions

       programs and algorithms

   
Question No: 2    ( Marks: 1 )    - Please choose one
 Which one of the following terms must relate to polymorphism?


       Static allocation

       Static typing
       Dynamic binding
       Dynamic allocation
   
Question No: 3    ( Marks: 1 )    - Please choose one
 What is true about function templates?






       The compiler generates only one copy of the function template
       The compiler generates a copy of function respective to each type of data
       The compiler can only generate copy for the int type data
       None of the given.
   
Question No: 4    ( Marks: 1 )    - Please choose one
 Which of the following is the best approach if it is required to have more than one functions having exactly same functionality and implemented on different data types?




       Templates
       Overloading
       Data hiding
       Encapsulation
   
Question No: 5    ( Marks: 1 )    - Please choose one
 template <>
class Vector<char*> { }

This is an example of partial specialization.




       True
       False
   
Question No: 6    ( Marks: 1 )    - Please choose one
 Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete, while classes like Sphere and Cube would normally be abstract.
       ► True
       ► False
   
Question No: 7    ( Marks: 1 )    - Please choose one
 A non-virtual member function is defined in a base class and overridden in a derived class; if that function is called through a base-class pointer to a derived class object, the derived-class version is used.

       ► True

       ► False
   
Question No: 8    ( Marks: 1 )    - Please choose one
 Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access





       public members of Derv.
       protected members of Derv.
       private members of Derv.
       protected members of Base.
   
Question No: 9    ( Marks: 1 )    - Please choose one
 In order to define a class template, the first line of definition must be:





       template <typename T>
       typename <template T>
       Template Class <ClassName>
       Class <Template T>
   
Question No: 10    ( Marks: 1 )    - Please choose one
 If there is a pointer p to objects of a base class, and it contains the address of an object of a derived class, and both classes contain a nonvirtual member function, ding(), then the statement p->ding(); will cause the version of ding() in the _____ class to be executed.






       Base
       Derived
       Abstract
       virtual
   
Question No: 11    ( Marks: 1 )    - Please choose one
 When the base class and the derived class have a member function with the same name, you must be more specific which function you want to call (using ___________).






       scope resolution operator
       dot operator
       null operator
       Operator overloading
   
Question No: 12    ( Marks: 1 )    - Please choose one
 Non Template Friend functions of a class are friends of ________instance/s of that class.

       All
       One specific
       All instances of one date type
       None of the given options

   
Question No: 13    ( Marks: 1 )    - Please choose one
 The find() algorithm




       ► finds matching sequences of elements in two containers.
       ► finds a container that matches a specified container.
       ► takes iterators as its first two arguments.
       ► takes container elements as its first two arguments.
   
Question No: 14    ( Marks: 1 )    - Please choose one
 If you define a vector v with the default constructor, and define another vector w with a one-argument constructor to a size of 11, and insert 3 elements into each of these vectors with push_back(), then the size() member function will return ______ for v and _____ for w.

        11 for v and 3 for w.


       0 for v and 0 for w.
       0 for v and 3 for w.
        3 for v and 11 for w.
   
Question No: 15    ( Marks: 1 )    - Please choose one
 Which of the following may not be an integral part of an object?




       State
       Behavior
       Protected data members
       All of given
   
Question No: 16    ( Marks: 1 )    - Please choose one
 Which is not the Advantage of inheritance?





       providing class growth through natural selection.
       facilitating class libraries.
       avoiding the rewriting of code.
       providing a useful conceptual framework.

   
Question No: 17    ( Marks: 1 )    - Please choose one
 class DocElement
{
public:
      virtual void Print() { cout << "Generic element"; }
};
class Heading : public DocElement
{
public:
      void Print() { cout << "Heading element"; }
};
class Paragraph : public DocElement
{
public:
      void Print() { cout << "Paragraph element"; }
};
void main()
{
      DocElement * p = new Paragraph();

      p->Print();
}

When you run this program, it will print out a single line to the console output.

What will be in that line?

Select one correct answer from the following list:

    Generic element

       Heading element

       Paragraph element

       Nothing will be printed.
    
Question No: 18    ( Marks: 1 )    - Please choose one
 When a virtual function is called by referencing a specific object by name and using the dot member selection operator (e.g., squareObject.draw()), the reference is resolved at compile time.

       True               
       ► False
   
Question No: 19    ( Marks: 1 )    - Please choose one
 In case of multiple inheritance a derived class inherits,





       Only the public member functions of its base classes
       Only the public data members of its base classes
       Both public data members and member functions of all its base classes
       Data members and member functions of any two base classes
   
Question No: 20    ( Marks: 1 )    - Please choose one
 When we write a class template the first line must be:




       template < class class_name>
       template < class data_type>
       template < class T >
Here T can be replaced with any name but it is preferable.
       class class-name()
class template<class_name>


    
Question No: 21    ( Marks: 1 )    - Please choose one
 Which of the following is incorrect line regarding function template?





       template<class T>
       template <typename U>
       Class<template T>
       template  < class T, class U>
   
Question No: 22    ( Marks: 1 )    - Please choose one
 An STL container can not be used to,




       ► hold objects of class employee.
       ► store elements in a way that makes them quickly accessible.
       ► compile c++ programs.
       ► organize the way objects are stored in memory
   
Question No: 23    ( Marks: 1 )    - Please choose one
 Algorithms can only be implemented using STL containers.

       True
       ► False
   
Question No: 24    ( Marks: 1 )    - Please choose one
 Consider a class named Vehicle, which of the following can be the instance of class Vehicle?
1.      Car
2.      Computer
3.      Desk
4.      Ahmed
5.      Bicycle
6.      Truck

       1, 4, 5

       2, 5, 6

       1, 2, 3, 6

       1, 5, 6

   
Question No: 25    ( Marks: 1 )    - Please choose one
 Consider the code below,
class Fred {
public:
Fred();
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];
...
}
Select the best option,
       Fred a[10]; calls the default constructor 09 times
Fred* p = new Fred[10];  calls the default constructor 10 times

       Produce an error

       Fred a[10]; calls the default constructor 11 times
Fred* p = new Fred[10];  calls the default constructor 11 times

       Fred a[10]; calls the default constructor 10 times
Fred* p = new Fred[10];  calls the default constructor 10 times

   
Question No: 26    ( Marks: 1 )    - Please choose one
 When a variable is define as static in a class then all object of this class,





       Have different copies of this variable
       Have same copy of this variable
       Can not access this variable
       None of given
   
Question No: 27    ( Marks: 1 )    - Please choose one
 The life of sub object is dependant on the life of master class in _____________.





       Separation
       Composition
       Aggregation
       None of the given
   
Question No: 28    ( Marks: 1 )    - Please choose one
 ___________, which means if A declares B as its friend it does NOT mean that A can access private data of B. It only means that B can access all data of A.






       Friendship is one way only
       Friendship is two way only
       NO Friendship between classes
       Any kind of friendship
   
Question No: 29    ( Marks: 1 )    - Please choose one
 Which of the following operators always takes no argument if overloaded?





       /
       -
       +
       ++
    
Question No: 30    ( Marks: 1 )    - Please choose one
 In Private --------------  only member functions and friend classes or functions of a derived class can convert pointer or reference of derived object to that of parent object

       specialization
       ► inheritance
       ► abstraction
       ► composition
   
Question No: 31    ( Marks: 1 )
 Write the syntax of declaring a pure virtual function in a class?
   
Question No: 32    ( Marks: 1 )
 What is meant by direct base class ?

   
Question No: 33    ( Marks: 2 )
 Describe the way to declare a template class as a friend class of any other class.


   
Question No: 34    ( Marks: 2 )
 What is the purpose of template parameter?

Question No: 35    ( Marks: 3 )
 Describe in simple words how we can use template specialization to enforce case sensitive specialization in String class.

Question No: 36    ( Marks: 3 )
 Can we use compiler generated default assignment operator in case our class is using dynamic memory? Justify your answer.

   
Question No: 37    ( Marks: 3 )
 Give the names of three ways to handle errors in a program.


   
Question No: 38    ( Marks: 5 )
 Consider the following code,

class Base{
private:
void base1();
protected:
void base2();
public:
void base3();
};

class Derived: public Base{
private:
void derived1();
protected:
void derived2();
public:
void derived3();
};

int main(){
Derived * derived = new Derived();
return 0;
}


Fill the table below to tell which member functions of Base and Derived classes we can access using the Derived pointer in the code indicated in bold.


Function Name
Availability (Yes / No)?
base2()
?
base3()
?
derived1()
?
derived2()
?
derived3()
?


   
Question No: 39    ( Marks: 5 )
 What is the output produced by the following program?

#include<iostream.h>

void sample_function(double test) throw (int);

int main()
{
            try
            {
                        cout <<”Trying.\n”;
                        sample_function(98.6);
                        cout << “Trying after call.\n”;
            }
            catch(int)
            {
                        cout << “Catching.\n”;
            }
           
            cout << “End program.\n”;
            return 0;
}
void sample_function(double test) throw (int)
{
            cout << “Starting sample_function.\n”;
            if(test < 100)
               throw 42;
}

   
Question No: 40    ( Marks: 10 )
 Write a publicly derived class “Employee” that is derived from base class named “Company”. Both classes will have function “create()”. Make virtual function of base class and override same function in derived class. Function create will have an output statement of your own choice.
In “main” Create an object of base class and call both functions with same object type.

   
Question No: 41    ( Marks: 10 )
 Write a program in C++ which creates three classes named as
1.      Equation
2.      Linear
3.      Quadratic
Where Linear and Quadratic are inherited from Equation
Each class has the method Graph. Graph method should be pure virtual in Equation class.
This method should be overridden in both the inherited classes. It is meant to display the Graph shape of its respective class. Graph method of Linear will display the message;
Straight line
Similarly, the Graph method of Quadratic will display the message;
Parabola
In main, call the Graph method of both the Linear and Quadratic equations polymorphically through the parent class (Equation).

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.