-
What is the output of below snippet?
try (InputStream is = ...)
{
// do stuff with is...
}
catch (IOException e)
{
// handle exception
}
-
- Runs successfully
- Compilation Error
- IOException
- Runtime Error
- None of these
Correct Option: A
Using java 7 and above, AutoCloseable objects can be opened in the try-block (within the ()) and will be automatically closed instead of using the finally block.