Considere o seguinte código em linguagem JAVA:
public class Codigo { public static void main(String[ ] args)
{
try { throwException (); } catch (Exception exception) { System.out.printf (" 1 ");}
} public static void throwException () throws Exception { try { System.out.printf (" 2 "); throw new Exception (); }
catch (RuntimeException runtimeException) { System.out.printf (" 3 ");} finally {System.out.printf (" 4 ");} } }
Teremos como saída a sequência:
- A 1 – 2 – 3 – 4
- B 3 – 4 – 1 – 2
- C 2 – 4 – 1
- D 1 – 2 – 4
- E 1 – 3 – 4