What is the difference between an IOException class that extends the Exception class and RuntimeException class that also extends Exception class?
Consider this code:
public class IOExceptionvsRuntime {
public static void main(String[] args) {
try {
throw new IOException();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
throw new RuntimeException();
}
}
Although both these classes extend the Exception class and yet the IOException has to be handled whereas compiler does not enforce handling of RuntimeException. I know the conceptual difference between the two that RuntimeException is an unchecked exception whereas IOException is a checked one.
It seems like there is some compiler-level handling, and I was interested in knowing more about how the compiler handles these.