I believe that java.lang.Exception is also a checked exception.But there is difference in behaviour between java.lang.Exception
vs any other checked exception such as IOException or SQLException.
See the following code compiled with Java version 7
try {
//empty try block
} catch (SQLException e) {
e.printStackTrace();
}
This gives the following comilation error:-
java.lang.Error: Unresolved compilation problem: Unreachable catch block for SQLException. This exception is never thrown from the try statement body
but the same code doesnt give any compilation error if there is no statement in try block:-
try {
// empty try block
} catch (Exception e) {
e.printStackTrace();
}
*Result:- No compialtion error *