What is the difference between checked and unchecked exceptions in Java?
Quick answer
Checked exceptions (subclasses of Exception other than RuntimeException) must be caught or declared with throws, while unchecked exceptions (RuntimeException and Error) do not have to be handled and usually signal programming bugs.
Checked exceptions such as IOException and SQLException represent failures the caller can reasonably be expected to handle or recover from, so the compiler forces you to deal with them. Unchecked exceptions such as NullPointerException, IllegalArgumentException and IndexOutOfBoundsException indicate bugs, and fixing the code is better than catching them. Error (for example OutOfMemoryError) signals serious JVM problems you should not catch.
Good practice: never swallow an exception silently, catch the most specific type, add context when you wrap it, and keep the original as the cause (new ServiceException("msg", e)). Many modern frameworks, including Spring, prefer unchecked exceptions because checked ones clutter method signatures.