[Solved] Analyze the following code, which exception does it display? (Exception handling, java)


The block:

catch (Exception ex) {
    System.out.println("NumberFormatException");
}

will catch all the exceptions, as the Exception class is the base class for all the exceptions.

When you catch Exception, you catch all the exceptions that extend Exception, which, all the exceptions do. Hence it produces the error that RuntimeException has already been caught

solved Analyze the following code, which exception does it display? (Exception handling, java)