Need help with the following question, can someone elaborate on the answer provided in the book.
The question is as follows:
10. Given:
Which exceptions will the code throw?
A. IOException with suppressed RuntimeException a
B. IOException with suppressed RuntimeException c
C. RuntimeException a with no suppressed exception
D. RuntimeException c with no suppressed exception
E. RuntimeException a with suppressed RuntimeException c
F. RuntimeException c with suppressed RuntimeException a
G. Compilation fails
According to me the answer should have been F, but the answer is D, I am not clear with the explanation to the answer. I tried modifying the code to the following to verify if there is any suppressed exception, and I could see that there is indeed one.
output:
Suppressedjava.lang.RuntimeException: a
Exception in
thread "main" java.lang.RuntimeException: c
at com.explore.pallavi.Animals.run(Animals.java:25)
at com.explore.pallavi.Animals.main(Animals.java:15)