National_Instruments
200-500 · Question #174
What is the output of the following code? try { class MyException extends Exception {}; try { throw new MyException; } catch (Exception $e) { echo "1:"; throw $e; }c atch (MyException $e) { echo…
The correct answer is E. 1:MyException. See the full explanation below for the reasoning.
Question
What is the output of the following code? try { class MyException extends Exception {}; try { throw new MyException; } catch (Exception $e) { echo "1:"; throw $e; }c atch (MyException $e) { echo "2:"; throw $e; }} catch (Exception $e) { echo get_class($e); }
Options
- AA parser error, try cannot be followd by multiple catch
- B1:
- C2:
- D1:Exception
- E1:MyException
- F2:MyException
- GMyException
How the community answered
(59 responses)- C2% (1)
- D5% (3)
- E81% (48)
- F8% (5)
- G3% (2)
Community Discussion
No community discussion yet for this question.