0% found this document useful (0 votes)
41 views17 pages

Handling in C++.: SNJB's KBJ COE, Chandwad Department of Computer Engineering

ppl mcq principle of programing languageprinciple of programing language ppl mcq principle of programing languageprinciple of programing language ppl mcq principle of programing languageprinciple of programing language

Uploaded by

Suryakant Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views17 pages

Handling in C++.: SNJB's KBJ COE, Chandwad Department of Computer Engineering

ppl mcq principle of programing languageprinciple of programing language ppl mcq principle of programing languageprinciple of programing language ppl mcq principle of programing languageprinciple of programing language

Uploaded by

Suryakant Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

SNJB’s KBJ COE, Chandwad Department of Computer Engineering

PART III: Structuring of Computations- Structuring the computation,


Expressions and statements, Conditional execution and iteration, Routines,
Style issues: side effects and aliasing, Exceptions, Case Study-Exception
handling in C++.

((MARKS)) 1
(1/2/3...)
((QUESTIO An exception is thrown using _____________ keyword in
N))
((OPTION_ throws
A))
((OPTION_ throw
B))
((OPTION_ threw
C))
((OPTION_ thrown
D))
((CORRECT B
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO
N))
((OPTION_ try
A))

1
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((OPTION_ catch
B))
((OPTION_ finally
C))
((OPTION_ None
D))
((CORRECT A
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Exception handlers are declared with ____________
N))
((OPTION_ try
A))
((OPTION_ catch
B))
((OPTION_ finally
C))
((OPTION_ None
D))
((CORRECT B
_CHOICE))
(A/B/C/D)

2
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Catch handler can have multiple parameters.
N))
((OPTION_ True
A))
((OPTION_ False
B))
((OPTION_
C))
((OPTION_
D))
((CORRECT A
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Which of the following statements are true about Catch \

3
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

N)) handler ?
1. It must be placed immediately after try block T
2. It can have multiple parameters
3. There must be only one catch handler for every try
block
4. There can be multiple catch handler for a try block T
5. Generic catch handler can be placed anywhere after
try block.
((OPTION_ Only 1, 4, 5
A))
((OPTION_ Only 1, 2, 3
B))
((OPTION_ Only 1, 4
C))
((OPTION_ Only 1, 2
D))
((CORRECT C
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO A try block can be nested under another try block –
N))
((OPTION_ Yes

4
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

A))
((OPTION_ No
B))
((OPTION_
C))
((OPTION_
D))
((CORRECT A
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO In nested try blocks, there is no need to specify catch
N)) handler for inner try block. Outer catch handler is
sufficient for the program.
a. True
b. False
((OPTION_ True
A))
((OPTION_ False
B))
((OPTION_
C))
((OPTION_
D))

5
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((CORRECT B
_CHOICE))
(A/B/C/D)
((EXPLANA For every try block, there must be at least one catch hander.
TION)) Otherwise, compiler will generate error.
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO In nested try block, if inner catch handler gets executed,
N)) then______________
((OPTION_ Program execution stops immediately
A))
((OPTION_ Outer catch handler will also get executed
B))
((OPTION_ Compiler will jump to the outer catch handler and then
C)) executes remaining executable statements of main()
((OPTION_ Compiler will execute remaining executable statements of
D)) outer try block and then the main()
((CORRECT D
_CHOICE))
(A/B/C/D)
((EXPLANA Compiler will execute remaining executable statements of
TION)) outer try block and then the main()
(OPTIONAL
)

6
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((MARKS)) 1
(1/2/3...)
((QUESTIO If inner catch handler is not able to handle the exception
N)) then__________
((OPTION_ Compiler will look for outer try handler
A))
((OPTION_ Program terminates abnormally
B))

((OPTION_ Compiler will check for appropriate catch handler of outer


C)) try block
((OPTION_ None of these
D))
((CORRECT C
_CHOICE))
(A/B/C/D)
((EXPLANA Compiler will check for appropriate catch handler of outer
TION)) try block
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Generic catch handler must be placed at the end of all the
N)) Catch handlers . Tr
((OPTION_ True
A))
((OPTION_ False
B))

7
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((OPTION_
C))
((OPTION_
D))
((CORRECT A
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Generic catch handler is represented by ______________
N))
((OPTION_ catch(..,)
A))
((OPTION_ catch(---)
B))

((OPTION_ catch(…)
C))
((OPTION_ catch( void x)
D))
((CORRECT C
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL

8
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((MARKS)) 1
(1/2/3...)
((QUESTIO In nested try blocks, if both inner and outer catch
N)) handlers are not able to handle the exception,
then______________

((OPTION_ Compiler executes only executable statements of main()


A))
((OPTION_ Compiler issues compile time errors about it
B))
((OPTION_ Program will be executed without any interrupt
C))
((OPTION_ Program will be terminated abnormally
D))
((CORRECT D
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Functions called from within a try block may also throw
n N))

9
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((OPTION_ True
A))
((OPTION_ False
B))
((OPTION_
C))
((OPTION_
D))
((CORRECT A
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Irrespective of exception occurrence, catch handler will
N)) always get executed.
((OPTION_ True
A))
((OPTION_ False
B))
((OPTION_
C))
((OPTION_
D))
((CORRECT B
_CHOICE))
(A/B/C/D)

10
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((EXPLANA Catch handler will only get execute when exception occurs
TION)) at runtime
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Throwing an unhandled exception causes standard library
N)) function _______________ to be invoked.

((OPTION_ stop()
A))
((OPTION_ aborted()
B))
((OPTION_ terminate()
C))
((OPTION_ abandon()
D))
((CORRECT C
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO An exception can be of only built-In type.
N))

11
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((OPTION_ True
A))
((OPTION_ False
B))
((OPTION_
C))
((OPTION_
D))
((CORRECT B
_CHOICE))
(A/B/C/D)
((EXPLANA An exception can be of any type, including class type that
TION)) we create.
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO How can we restrict a function to throw certain exceptions?
N))
((OPTION_ Defining multiple try and catch block inside a function
A))
((OPTION_ Defining generic function within try block
B))
((OPTION_ Defining function with throw clause
C))
((OPTION_ It is not possible in C++ to restrict a function
D))
((CORRECT C
_CHOICE))
12
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Attempting to throw an exception that is not supported by a
N)) function call results in calling _____________ library
function.
((OPTION_ indeterminate()
A))
((OPTION_ unutilized()
B))
((OPTION_ unexpected()
C))
((OPTION_ unpredicted()
D))
((CORRECT C
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)

13
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((QUESTIO Return type of uncaught_exception() is________________


N))
((OPTION_ int
A))
((OPTION_ bool
B))
((OPTION_ char *
C))
((OPTION_ double
D))
((CORRECT B
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO
N)) Can we write throw clause inside catch handler?
((OPTION_ Yes
A))
((OPTION_ No
B))
((OPTION_
C))

14
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((OPTION_
D))
((CORRECT A
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

((MARKS)) 1
(1/2/3...)
((QUESTIO Can we define our exceptions in CPP?
N))
((OPTION_ Yes
A))
((OPTION_ No
B))
((OPTION_
C))
((OPTION_
D))
((CORRECT A
_CHOICE))
(A/B/C/D)
((EXPLANA None
TION))
(OPTIONAL
)

15
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

((MARKS)) 1
(1/2/3...)
((QUESTIO What is the output of this program?
N)) #include <iostream>
using namespace std;
int main()
{
int x = -1;
try
{
if (x < 0)
{
throw x;
}
else
{
cout<<x;
}
}
catch (int x )
{
cout << "Exception occurred: Thrown value is " <<
x << endl;
}
return 0;
}
((OPTION_ -1
A))
((OPTION_ 0
B))
((OPTION_ Exception Occurred: Thrown value is -1
C))
((OPTION_ error

16
SNJB’s KBJ COE, Chandwad Department of Computer Engineering

D))
((CORRECT C
_CHOICE))
(A/B/C/D)
((EXPLANA As the given value is -1 and according to the condition, We
TION)) are arising an exception.
(OPTIONAL
)

Refer more questions on exception handling in C++ of last OOP MCQs

17

You might also like