This was an interview question. What is the main difference between unchecked exception and error as both are not caught? They will terminate the program.
Note: a RuntimeException IS an unchecked exception
An unchecked exception would be one that is known to be possible at a point in the execution but is not caught, for example a NullPointerException is always a possibility if you don't check for them and will cause your program to terminate. You could check for it by wrapping code in try-catch, but this is not enforced (unlike a checked exception that will enforce that the exception is handled in some way).
An error is something that can occur at any point during execution and can't really be caught because it is not eplicitly caused by a particular method call etc. For example an OutOfMemoryError or a StackOverflowError. Both of these could occur at any time and will cause your application to terminate. Catching these errors make no sense as they indicate that something has happened that you won't be able to recover from.
Error: These are exceptional conditions that are external to the application, and that the application usually cannot anticipate or recover from.
Runtime exception : These are exceptional conditions that are internal to the application, and that the application usually cannot anticipate or recover from.
You may want to read this :