Exceptions - Quiz
Total: 3 questions
1. How to avoid execution of the finally block?
How to avoid execution of the finally block?
The finally block won't be executed only if it is called System.exit(). In this case the program will terminate abnormally without executing the finally block.
2. What the try-with-resources block is used for?
What the try-with-resources block is used for?
It gives the possibility to declare resources in the try block so they can be closed without doing it explicitly in a finally block.
3. Which objects can be used in the try-with-resources block as a resource?
Which objects can be used in the try-with-resources block as a resource?
Any object that implements java.lang.AutoCloseable.
Page 1 of 1