FINALTERM EXAMINATION
Spring 2010
CS304- Object Oriented Programming (Session - 3)
Time: 90 min
M a r k s: 58
CS304 Question No: 1
Which one of the following terms must relate to polymorphism?
► Static allocation
► Static typing
► Dynamic binding
► Dynamic allocation
CS304 Question No: 2
Which of the following causes run time binding?
► Declaring object of abstract class
► Declaring pointer of abstract class
► Declaring overridden methods as non-virtual
► None of the given
CS304 Question No: 3
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
CS304 Question No: 4
Which of the following is the best approach to implement generic algorithms with minimum number of coding lines?
► Templates
► Overloading
► Overriding
► Friend function/class
CS304 Question No: 5
Like template functions, a class template may not handle all the types successfully.
► True
► False
CS304 Question No: 6
A class template may inherit from another class template.
► True
► False
CS304 Question No: 7
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.
CS304 Question No: 8
A copy constructor is invoked when
► a function do not returns by value.
► an argument is passed by value.
► a function returns by reference.
► an argument is passed by reference.
CS304 Question No: 9
Each try block can have ______ no. of catch blocks.
► 1
► 2
► 3
► As many as necessary.
CS304 Question No: 10
class DocElement
{
public:
virtual void Print() { cout <
<
};
class Heading : public DocElement
{
public:
void Print() { cout <
<
};
class Paragraph : public DocElement
{
public:
void Print() { cout <
<
};
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.
CS304 Question No: 11
Suppose we have two derived classes from a single class, can we write a
method with same name in both these derived classes ? Choose the best
option.
► No
► Only if the two classes have the same name
► Only if the main program does not declare both kinds
► Yes
CS304 Question No: 12
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
CS304 Question No: 13
Considering the resolution order in which compiler search for functions in a program; the first priority is given to,
► general template
► partial specialization
► complete specialization
► ordinary function
CS304 Question No: 14
Vectors contain contiguous elements stored as a[an] ___.
► variable
► array
► function
► datatype
CS304 Question No: 15
By default the vector data items are initialized to ____
► 0
► 0.0
► 1
► null
CS304 Question No: 16
One purpose of an iterator in the STL is to connect algorithms and containers.
► True
► False
CS304 Question No: 17
Algorithms can only be implemented using STL containers.
► True
► False
CS304 Question No: 18
In ________, a base class can be replaced by its derived class,
► Sub-typing
► Super-typing
► Multiple-typing
► Restricted-typing
CS304 Question No: 19
this pointer does not point to current object of any class,
► True
► False
CS304 Question No: 20
Which of the following operator(s) take(s) one or no argument if overloaded?
► ++
► -
► +
► All of the given
CS304 Question No: 21
Which of the following operators can not be overloaded?
► Scope resolution operator ( :: )
► Insertion operator ( <
<
► Extraction operator ( >> )
► The relation operator ( > )
CS304 Question No: 22
The type that is used to declare a reference or pointer is called its ---------
► default type
► static type
► abstract type
► reference type
CS304 Question No: 23
------------- members are somewhere between public and private members. They are used in inheritance
► protected
► public
► private
► global
CS304 Question No: 24
Which of these are examples of error handling techniques ?
noitanimreTlamronbA►
► Graceful Termination
► Return the illegal
► all of the given
CS304 Question No: 25
_______ is a relationship
► Inheritance
► Polymarphism
► abstraction
► encapsulation
CS304 Question No: 26
Graphical representation of the classes and objects is called object model it shows -------
► Class Name only
► Class Name and attributes
► Relationships of the objects and classes
► all of the given
CS304 Question No: 27 ( M a r k s: 2 )
Describe the way to declare a template function as a friend of any class.
CS304 Question No: 28 ( M a r k s: 2 )
Give the names of any two types of template.
CS304 Question No: 29 ( M a r k s: 2 )
Explain the statement below,
vector ivec(4, 3);
CS304 Question No: 30 ( M a r k s: 2 )
Q. Enlist the kinds of association w.r.t Cardinality (3)
CS304 Question No: 31 ( M a r k s: 3 )
Give three advantages that Iterators provide over Cursors.
CS304 Question No: 32 ( M a r k s: 3 )
Give the differences between virtual inheritance and multiple inheritance.
CS304 Question No: 33 ( M a r k s: 3 )
If we declare a function as friend of a template class will it be a
friend for a particular data type or for all data types of that
class.
CS304 Question No: 34 ( M a r k s: 5 )
See the 5 code snippets below and tell whether these are correct or
incorrect also justify your answers in the table given at the end.
Snippet No.1
template
class A {
} ;
template
class B : public A
{ … }
Snippet No.2
template
class B : public A
{ … }
Snippet No.3
class B : public A
{ … }
Snippet No.4
template
class B : public A
{ … };
Snippet No.5
template
class B : public A
{ … }
Table:
Snippet No. |
Is it correct or not (Correct/ Incorrect) |
Justification of your answer |
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
CS304 Question No: 35 ( M a r k s: 5 )
What is the output produced by the following program?
#include
void sample_function(double test) throw (int);
int main()
{
try
{
cout <<”trying.\n”;
<<”trying.\n”;
sample_function(98.6);
cout <
<
}
catch(int)
{
cout <
<
}
cout <
<
return 0;
}
void sample_function(double test) throw (int)
{
cout <
<
if(test < 100)
throw 42;
}
CS304 Question No: 36 ( M a r k s: 5 )
Suppose the base class and the derived class each have a member
function with the same signature. When you have a pointer to a base
class object and call a function member through the pointer, discuss
what determines which function is actually called, the base class member
function or the derived-class function.