C++ Programming :: Exception Handling

NA
SHSTTON
4
Solv. Corr.
3
Solv. In. Corr.
7
Attempted
0 M:0 S
Avg. Time

1 / 8

Choose the correct option.

Which of the following is the most preferred way of throwing and handling exceptions?


AThrow by value and catch by reference.

BThrow by reference and catch by reference.

CThrow by value and catch by value

DThrow the pointer value and provide catch for the pointer type.

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
3
Solv. Corr.
10
Solv. In. Corr.
13
Attempted
0 M:0 S
Avg. Time

2 / 8

Choose the correct option.

An exception specification begins with the keyword


Aexception

Btry

Cthrow

Dcatch

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
9
Solv. Corr.
2
Solv. In. Corr.
11
Attempted
0 M:0 S
Avg. Time

3 / 8

Choose the correct option.

You can throw


Aa scalar variable

Bone throw of each scale type

Ca programmer-defined class object

Dall of these

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
3
Solv. Corr.
7
Solv. In. Corr.
10
Attempted
0 M:0 S
Avg. Time

4 / 8

Choose the correct option.

The primary purpose of exception specification is


Adocumentation

Bobject-orientedness

Cstructure

Dreduction of code.

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
7
Solv. Corr.
4
Solv. In. Corr.
11
Attempted
1 M:5 S
Avg. Time

5 / 8

Choose the correct option.

A default exception block must be placed


Afirst among the catch blocks

Blast among the catch blocks

Cglobally at the top of the file

Dat the end of all code in program.

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
5
Solv. Corr.
6
Solv. In. Corr.
11
Attempted
0 M:0 S
Avg. Time

6 / 8

Choose the correct option.

A default catch block catch


Aall thrown objects

Bno thrown objects

Cany thrown objects that has not been caught by an earlier catch block

Dall thrown objects that have been caught by an earlier catch block.

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
1
Solv. Corr.
10
Solv. In. Corr.
11
Attempted
0 M:0 S
Avg. Time

7 / 8

Choose the correct option.

When is std::bad_alloc exception thrown?


AWhen new operator cannot allocate memory

BWhen alloc function fails

CWhen type requested for new operation is considered bad, thisexception is thrown

DWhen delete operator cannot delete teh allocated (corrupted) object

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
6
Solv. Corr.
5
Solv. In. Corr.
11
Attempted
0 M:0 S
Avg. Time

8 / 8

Choose the correct option.

Which of the following is not a standard exception built in C++


Astd::bad_creat

Bstd::bad_alloc

Cstd::bad_cast

Dstd::bad_typeid

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace