Interview questions

C++ Error Handling concepts


C++ Error Handling: Interview questions

<<Previous  Next>>

Describe the way to handle run time error in C++.

Latest answer: A runtime error is handled in C++ in the following manner:

- Write the code where the error is predicted after the keyword try.
- Write the solution if a particular exception occurs in the catch block by specifying a parameter which is thrown from the try block.
Or
- Throw the error object by using throw(Exceptiontype object) after try keyword.

  1. Describe the way to handle run time error in C++.
  2. Explain the exception specification.
Also read

Explain how we implement exception handling in C++.

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..................

Explain terminate() and unexpected() function.

terminate() is a library function which by default aborts the program
It is called whenever the exception handling mechanism cannot find a handler for a thrown exception...................

Describe Exception handling concept with an example.

Exceptions: Exceptions are certain disastrous error conditions that occur during the execution of a program. They could be errors that cause the programs to fail or certain conditions that lead to errors. If these run time errors are not handled by the program, OS handles them and program terminates..................

Illustrate Rethrowing exceptions with an example.

Rethrowing an expression from within an exception handler can be done by calling throw, by itself, with no exception. This causes current exception to be passed on to an outer try/catch sequence.......................

<<Previous  Next>>



Write your comment - Share Knowledge and Experience


 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring