Yes. If the exception class specified in the catch clause has subclasses, any exception object that is a subclass of the specified Exception class will be caught by that single catch block.
E.g..
The catch block above will catch IOException and all its subclasses e.g. FileNotFoundException etc.
E.g..
try {
// Some code here that can throw an IOException
}
catch (IOException e) {
e.printStackTrace();}
No comments:
Post a Comment