If we throw an exception in the main method and don’t handle it, it will work fine. In fact
public static void main(String[] args) throws IOException { throw new IOException();
But Java requires that all checked exceptions be handled in the program, so IOException needs to be handled. Who actually handles the IOException in this case?
Note that the Java language specification specifies that an Exception is thrown if it is enclosed with a try block containing a catch clause, the type is a supertype of exception.
source share