Home » JAVA Programming » Interfaces » Question
  1. What is the output of below snippet?
    try (InputStream is = ...) 
    {
    // do stuff with is...
    }
    catch (IOException e)
    {
    // handle exception
    }
    1. Runs successfully
    2. Compilation Error
    3. IOException
    4. Runtime Error
    5. 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.



Your comments will be displayed only after manual approval.