I came to know from question that when some Error like NoClassDefFoundError occurs in Java
This is a pretty critical error, as the program cannot be initiated by the JVM.
Then:
try {
//statements
} catch (NoClassDefFoundError e) { // catching NoClassDefFoundError
e.printStackTrace();
//do something when Error occurred
} catch(Error e){ // catching Error
e.printStackTrace();
//do something when Error occurred
}catch (Exception e) {
e.printStackTrace();
//do something when Exception occurred
}
Questions:
Does it have any significance by catching
Errorin try catch block as program will not be initiated by the JVM, will these block will ever execute?If not then why catching mechanism for
Erroris allowed in Java. If yes then when and how?