Id 101
Question Run time error is known as ______
A Logical error
B Syntactic error
C Exception
D All of the above mentioned
Answer C
Marks 1
Unit IV
Id 102
Question How the exception is throw
A throw exception
B throw(exception)
C throw
D All of the above
Answer D
Marks 1
Unit IV
Id 103
Question Can we throw exception more than one time
A True
B False
C
D
Answer A
Marks 1Unit IV
Id 104
Question Which statement we have to use rethrowing exception
A throw(exception)
B Throw
C Both a and b
D None of the above mentioned
Answer B
Marks 1
Unit IV
Id 105
Question Exception can be handle if_______
A Throwing argument is match with catch block
B Throwing argument is not match with catch block
C Exception is not thrown
D None of the abve
Answer A
Marks 1
Unit IV
Id 106
Question With this concept same algorithm can be used for different data types
A Procedure oriented paradigm
B Generic programming
C Both a and b
D None of the above
Answer B
Marks 1
Unit IV
Id 106
Question Template is a way creating generalize functions and classes which are applicable for all
data types
A False
B True
C
D
Answer B
Marks 1
Unit IV
Id 107
Question Class template is applicable for ___.
A For function onlyB For that class only
C Both a and b
D None of the above mentioned
Answer B
Marks 1
Unit IV
Id 108
Question Function template is applicable for_________.
A For function only
B For that class only
C Both a and b
D None of the above mentioned
Answer A
Marks 1
Unit IV
Id 109
Question How many kinds of parameters are there in c++
A 1
B 2
C 3
D 4
Answer C
Marks 1
Unit IV
Id 110
Question Which type of program is recommended to include in try block
A Static memory allocation
B Dynamic memory allocation
C Const reference
D Pointer
Answer B
Marks 1
Unit IV
Id 111
Question How to handle error in destructor
A Throwing
B Terminate
C Both a and b
D None of the mentioned
Answer B
Marks 1
Unit IV
Id 112
Question In catch statement we have multiple parameters
A Yes
B No
C
D
Answer B
Marks 1
Unit IV
Id 113
Question ------kind of exceptions are in c++.
A Handled
B Static
C Both a and b
D Unhandled
Answer A
Marks 1
Unit IV
Id 114
Question Pick up the correct statement
A To throw exception we have to use catch statement
B Error occurring code is placed in try block
C We can not have multiple throwing mechanism in c++
D Both and b
Answer B
Marks 1
Unit IV
Id 115
Question Can we used constructor for exception handling
A Yes
B No
C
D
Answer A
Marks 1
Unit IV
Id 116
Question Class template can be overloaded
A True
B False
CD
Answer B
Marks 1
Unit IV
Id 117
Question ______is a generic class handler
A Catch(---)
B Catch(-,-)
C Catch(…)
D Catch(void)
Answer C
Marks 1
Unit IV
Id 118
Question If the exception is not handled then which standard library function get invoked
A stop()
B terminate()
C Read()
D Write()
Answer B
Marks 1
Unit IV
Id 119
Question Exception can be only built in type
A True
B False
C
D
Answer A
Marks 1
Unit IV
Id 120
Question What will be output of program
#include<iostream>
using namespace std;
template<class T>
T display(T x)
{
cout<< “using template x=”<<x<<“\n”;
}
int display(int x)
{cout<<“Normal display x=”<<x <<“\n”;
}
int main()
{
display(2.3);
display(3);
diplay(1.1);
}
A Normal display x=2.3
Using template x=3
Normal display x=1.1
B using template x=2.3
Normal display x=3
using template x=1.1
C using template x=3
Normal display x=2.3
using template x=1.1
D None of the above
Answer B
Marks 2
Unit IV
Id 121
Question In nested try blocks, there is no need to specify catch handler for inner try block. Outer
catch handler is sufficient for the program
A True
B False
C
D
Answer B
Marks 1
Unit IV
Id 122
Question Can we write try block within try block
A True
B False
C
D
Answer A
Marks 1
Unit IV
Id 123
Question Can we prevent a function from throwing any exceptions
A YesB No
C
D
Answer A
Marks 1
Unit IV
Id 124
Question What is return type of uncaught_exception() is----
A Char*
B Double
C Int
D Bool
Answer D
Marks 1
Unit IV
Id 125
Question Can we write a throw statement inside catch statement
A Yes
B No
C
D
Answer A
Marks 1
Unit IV
Id 126
Question We can define our own exceptions in c++
A False
B True
C
D
Answer B
Marks 1
Unit IV
Id 127
Question Stack unwinding deals with
A Polymorphism
B inheritance
C Exception handling
D Classes
Answer C
Marks 1
Unit IV
Id 128
Question What is STL
A Standard Term Library
B Standard Tree Library
C Standard Template Library
D None of the above mentioned
Answer C
Marks 1
Unit IV
Id 129
Question Pick up the correct statement
• Catch statement be placed immediately after try block
• It can have multiple parameters
• There must be multiple catch handler for a try block
• Generic catch statement we can placed anywhere in program
A i and ii
B i and iii
C i and iv
D i , ii and iii
Answer B
Marks 2
Unit IV
Id 130
Question Generic catch should be placed at
A End of all statement
B Before try
C Before throw
D Inside try
Answer A
Marks 1
Unit IV
Id 131
Question Irrespective of exception occurrence, catch handler will be always executed
A Yes
B No
C
D
Answer B
Marks 1
Unit IV
Id 132
Question From where does the template class can derived
A Regular non-templated c++ class
B Templated class
C Both a and b
D None of the above mentioned
Answer C
Marks 2
Unit IV
Id 133
Question What is done by compiler for templates
A Type-safe
B Code elimination
C Portability
D All of the above mentioned
Answer A
Marks 2
Unit IV
Id 134
Question Catch handler itself may detect and throw an exception
A True
B False
C
D
Answer A
Marks 1
Unit Iv
Id 135
Question If the thrown exception will not be caught by any catch statement then it will be passed to
next outer try/catch sequence for processing.
A False
B True
C
D
Answer B
Marks 1
Unit IV
Id 136
Question While specifying the exceptions, the type-list specifies the________ that may be thrown.
A How many exceptions
B Type of exception
C Both a and b
D None of the above mentionedAnswer B
Marks 2
Unit IV
Id 137
Question When an exception is rethrown ,it will not be caught by the__________or other catch in
that group.
A Same catch
B Nested catch
C Both a and b
D None of the above mentioned
Answer A
Marks 2
Unit IV
Id 138
Question Try block can throw any exception
A True
B False
C
D
Answer B
Marks 1
Unit IV
Id 139
Question Pick up the correct statement from the following
• Multiple catch statement are there in c++.
• We have generic catch statement to handle all type of exception
• Try block is used to throw and exception
A i and iii
B i
C ii
D i and ii only
Answer D
Marks 2
Unit IV
Id 140
Question When an exception is not caught
A Program is go in wait condition
B Program is aborted
C Program works fine way
D None of the above mentioned
Answer BMarks 1
Unit IV
Id 141
Question We can place two or more catch blocks together to catch and handle multiple types of
exceptions thrown by a try blocks
A True
B False
C
D
Answer A
Marks 1
Unit IV
Id 142
Question It is also possible to make a catch statement to catch all types of exceptions using ellipses
as its arguments
A True
B False
C
D
Answer A
Marks 1
Unit IV
Id 143
Question We can restrict a function to throw only a set of specified exceptions by adding a throw
specification clause to the function definition.
A True
B False
C
D
Answer A
Marks 1
Unit IV
Id 144
Question We may also use non-type parameters such basic or derived data types as arguments
template
A True
B False
C
D
Answer A
Marks 1
Unit IV
Id 145
Question Pick up the correct statement from the following related with overloading of template
functions
• Call an ordinary function that has an exact match
• Call a template function that could be created with an exact macth
• Try normal overloading resolution to ordinary functions and call the one
that matches
A 1 and 2 only
B 2 and 3 only
C All of the above
D None of the above mentioned
Answer C
Marks 2
Unit IV
Id 146
Question What will be output of the a following program
#include<iostream>
using namespace std;
template <class T>
void display(T x)
{
cout<<“Template display:”<<x<< “\n”;
}
void display(int x)
{
cout<<“Explicit display:”<<x <<“\n”;
}
int main()
{
display(100);
display(12.34);
display(„c‟);
}
A Template display:100
Template display:12.34
Template display: c
B Explicit display:100
Template display:12.34
Template display: c
C Explicit display:100
Template display:12.34
Explicit display: c
D Template display:100
Template display:12.34Template display: c
Answer B
Marks 2
Unit IV
Id 147
Question What will be output of program
#include <iostream>
using namespace std;
int main()
{
cout <<"Start\n";
try {
cout <<"Inside try block\n";
throw 100;
cout << "This will not execute";
}
catch (int i) {
cout <<"Caught an exception -- value is: ";
cout <<i <<"\n";
}
cout <<"End";
return 0;
}
A Start
Inside try block
Caught an exception -- value is: 100
End
B Start
End
C Start
Inside try block
End
D None of the above mentioned
Answer A
Marks 2
Unit IV
Id 148
Question What will be output of following program
#include <iostream>
using namespace std;
void Xhandler(int test)
{
try{
if(test) throw test;else throw "Value is zero";
}
catch(int i) {
cout << "Caught Exception #: " <<i <<'\n';
}
catch(const char *str) {
cout <<"Caught a string: ";
cout << str <<'\n';
}
}
int main()
{
cout <<"Start\n";
Xhandler(1);
Xhandler(2);
Xhandler(0);
Xhandler(3);
cout << "End";
return 0;
}
A Start
Caught Exception #: 1
Caught Exception #: 2
Caught Exception #: 0
Caught Exception #: 3
End
B Start
Caught Exception #: 1
Caught Exception #: 2
Caught a string: 0
Caught Exception #: 3
End
C Start
Caught Exception #: 1
Caught Exception #: 2
Caught a string: Value is zero
Caught Exception #: 3
End
D None of the mentioned
Answer C
Marks 2
Unit IV
Id 149
Question What will be output of program
#include <iostream>using namespace std;
void Xhandler(int test)
{
try{
if(test==0) throw test; // throw int
if(test==1) throw 'a'; // throw char
if(test==2) throw 123.23; // throw double
}
catch(int i) { // catch an int exception
cout <<"Caught an integer\n";
}
catch(...) { // catch all other exceptions
cout <<"Caught One!\n";
}
}
int main()
{
cout <<"Start\n";
Xhandler(0);
Xhandler(1);
Xhandler(2);
cout <<"End";
return 0;
}
A Start
Caught One!
Caught One!
Caught One!
End
B
C Start
Caught an integer
Caught One!
Caught One!
End
D Start
Caught One!
Caught an integer
Caught One!
End
Answer C
Marks 2
Unit None of the above mentioned
Id 150
Question What will be output of following program#include <iostream>
using namespace std;
template <class Type1, class Type2> class myclass
{
Type1 i;
Type2 j;
public:
myclass(Type1 a, Type2 b) { i = a; j = b; }
void show() { cout <<i << ' ' <<j <<'\n'; }
};
int main()
{
myclass<int, double>ob1(10, 0.23);
myclass<char, char *>ob2('X', "Templates add power.");
ob1.show(); // show int, double
ob2.show(); // show char, char *
return 0;
}
A 10 0.23
X Templates add power.
B 0.23 10
X Template add power
C 10 10
X template add power
D Compilation error
Answer A
Marks 2
Unit IV
Id 151
Question We can combine operator overloading with a class
A True
B False
C
D
Answer A
Marks 1
Unit IV
Id 152
Question If you overload a generic function, that overloaded function overrides (or "hides") the
generic function relative to that specific version.
A True
B False
C
DAnswer A
Marks 1
Unit IV
Id 153
Question What will be output of following programming
#include <iostream>
using namespace std;
template <class T>
T GetMax (T a, T b) {
T result;
result = (a>b)? a : b;
return (result);
}
int main () {
int i=5, j=6, k;
long l=10, m=5, n;
k=GetMax<int>(i,j);
n=GetMax<long>(l,m);
cout <<k << endl;
cout <<n <<endl;
return 0;
}
A 6
10
B 5
5
C 10
10
D Compilation error
Answer A
Marks 2
Unit IV
Id 154
Question What will be output of following program
#include <iostream>
using namespace std;
template <class T>
class mypair {
T a, b;
public:
mypair (T first, T second)
{a=first; b=second;}
T getmax ();
};template <class T>
T mypair<T>::getmax ()
{
T retval;
retval = a>b? a : b;
return retval;
}
int main () {
mypair <int>myobject (100, 75);
cout << myobject.getmax();
return 0;
}
A 75
B 100
C 75
100
D Compilation error
Answer B
Marks 2
Unit IV
Id 155
Question What will be output of following program
#include <iostream>
#include <exception>
using namespace std;
class myexception: public exception
{
virtual const char* what() const throw()
{
return "My exception happened";
}
} myex;
int main () {
try
{
throw myex;
}
catch (exception&e)
{
cout << e.what() <<endl;
}
return 0;
}
A Exception happened
B My exception happened.C Run Time error
D Compilation error
Answer B
Marks 2
Unit IV
Id 156
Question Pick up the correct statement from following
1.Exception handling is not supported c++
2.Template support generic programming in c++
3.overloading of function template is possible in c++
4.generic catch template can handle all types of exceptions
A 2 and 3 only
B 3 and 4 only
C 1, 2 and 3 only
D 2, 3 and 4 only
Answer D
Marks 2
Unit 4
0 Comments
Please feel free to comment. Being diploma students We are always ready to help diploma Students