concept catch in category java

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide MEAP V03.
Exam Tip Different local variables can have different scopes. The scope of local variables may be shorter than or as long as the scope of method parameters. The scope of local variables is less than the scope of a method if they’re declared in a sub-block (within braces {}) in a method. This sub-block can be an if statement, a switch construct, a loop, or a try-catch block (discussed in chapter 7).
Using try-catch-finally blocks to handle exceptions
class HandleExceptions { void method6() { try {} catch (Error e) {} } void method7() { try {} catch (Exception e) {} } void method8() { try {} catch (Throwable e) {} } void method9() { try {} catch (RuntimeException e) {} } void method10() { try {} catch (FileNotFoundException e) {} #A } }In the preceding code, method6(), method7(), method8(), and method9() compile even though their try block doesn’t define code to throw the exception being handled by its catch block. But method10() won’t compile.
Exam tip A method can declare to throw any type of exception, checked or unchecked, even if it doesn’t do so. But a try block can’t define a catch block for a checked exception (other than Exception) if the try block doesn’t throw that checked exception or use a method that declares to throw that checked exception.
Figure 12.16 A visual way to remember that the order matters for exceptions caught in the catch blocks
![]()

This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.
Purpose: A finally block can’t be placed before the catch blocks. A number of programmers have compared this question with placing the label default before the label case in a switch construct. Though the latter approach works, the finally and catch blocks aren’t so flexible.
Using try-catch-finally blocks to handle exceptions
When you work with exception handlers, you often hear the terms try, catch, and finally. Before you start to work with these concepts, I’ll answer three simple questions:
Try what? First, you try to execute your code. If it doesn’t execute as planned, you handle the exceptional conditions using a catch block. Catch what? You catch the exceptional event arising from the code enclosed within the try block and handle the event by defining appropriate exception handlers.
Listing 7.1. Code flow with multiple catch statements and a finally block
![]()