C++ Programming :: Exception Handling

Home > C++ Programming > Exception Handling > General Questions

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

1 / 8

 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
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

2 / 8

 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
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

3 / 8

 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
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

4 / 8

 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
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

5 / 8

 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
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

6 / 8

 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
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

7 / 8

 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
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

8 / 8

 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