1. Exception class has 5 constructors
    empty constructor
    constructor accepting string message
    constructor accepting string message and throwable
    constructor accepting throwable
    constructor accepting string message, throwable, boolean (enableSuprresion), boolean (writableStackTrace)
  2. Autoclosable
    It is an interface
    It has abstract public void close method that throws Exception.
    You have to overried close method properly, overriden close method may not throw an exception.
    if overriden close method throws an exception, then try with resource block should handle that exception or enclosing method should use throw clause.
    when more than one resources are in try() block, they are closed in reversed order than how they are declared.
    if both try and close block throw an exception then one thrown by close block is suppressed.
  3. try with resource
    try () {}
    ; separated multiple lines are allowed in try () block. Last line need not have semicolon in the end.
    all the variables in try () block must be final or effectively final.
  4. RuntimeException extends from Exception
    But if class extends Exception then that becomes a checked exception
    IOException is checked exception
    IllegalStateException is unchecked exception
  5. Throwable and Error are not recommended to catch

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.