Multiple choice technology programming languages

Which of the following represents the correct syntax for re-throwing an exception.

  1. try {throw 3;} catch(int i){ rethrow; }

  2. try {throw 3; rethrow ;} catch(int i){}

  3. try {throw 3;} catch(int i){ rethrow 3; }

  4. try {throw 3;} catch(int i){ throw; }

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In C++, the correct syntax to re-throw the currently caught exception is a standalone throw; statement within a catch block. Specifying throw 3; or rethrow creates a new exception or results in syntax errors, as rethrow is not a keyword. Thus, the option using throw; is the syntactically correct choice.