nerdexam
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)
  • C
    2% (1)
  • D
    5% (3)
  • E
    81% (48)
  • F
    8% (5)
  • G
    3% (2)

Community Discussion

No community discussion yet for this question.

Full 200-500 Practice