C++ Exception Handling Question:

Download Job Interview Questions and Answers PDF

How to implement exception handling in C++?

C++ Exception Handling Interview Question
C++ Exception Handling Interview Question

Answer:

Exception handling in C++ is implemented by using the try{} and catch(){} statements.

When a try block throws an exception, the program leaves the try block and enters the catch statement of the catch block.

If they type of the object thrown matches the arg type in the catch block, catch block is executed for handling the code.

If they are not caught, abort() function is executed by default.

When no exception is deteted or thrown then the control goes to the statement below the catch block.

Download C++ Exception Handling Interview Questions And Answers PDF

Previous QuestionNext Question
Explain unexpected() function?An exception is thrown using _____________ keyword in CPP.

a. throws
b. throw
c. threw
d. thrown?