ExamQuestions.com

Register
Login
Java SE 8 Programmer II Exam Questions

Oracle

Java SE 8 Programmer II

14 / 130

Question 14:

Given the code fragments: 4. void doStuff() throws ArithmeticException, NumberFormatException, Exception{ 5.if (Math.random() >-1 throw new Exception ("Try again"); 6. } and 24. try { 25.doStuff ( ): 26. } catch (ArithmeticException | NumberFormatException | Exception e){ 27.System.out.println (e.getMessage()); } 28. catch (Exception e) { 29.System.out.println (e.getMessage()); } 30. } Which modification enables the code to print Try again? 

Answer options:

A. Comment the lines 28, 29 and 30.
B. Replace line 26 with: } catch (Exception | ArithmeticException | NumberFormatException e) {
C. Replace line 26 with: } catch (ArithmeticException | NumberFormatException e) {
D. Replace line 27 with: throw e;