GIAC
GSSP-JAVA · Question #22
Mark works as an Application Developer for XYZ Solutions Inc. He writes the following code. public class TestDemo{public static void main(String[] args){ {try{int x =0;int d= 5/x;}catch(Exception…
The correct answer is C. Compilation fails. See the full explanation below for the reasoning.
Question
Mark works as an Application Developer for XYZ Solutions Inc. He writes the following code. public class TestDemo{public static void main(String[] args){ {try{int x =0;int d= 5/x;}catch(Exception ex){System.out.println("Exception");} catch(ArithmeticException ae){System.out.println("Arithmetic Exception");}}} What is the result when Mark tries to compile and execute the code?
Options
- AException
- BAn exception is thrown at runtime.
- CCompilation fails.
- DArithmetic Exception
How the community answered
(33 responses)- A3% (1)
- B6% (2)
- C76% (25)
- D15% (5)
Community Discussion
No community discussion yet for this question.