Exception
an object representing an unexpected event which is a disruption in the normal flow of code; these events can be fixed through the process of exception handling
Error vs. exception
errors should never happen in normal running of program, indicating a serious problem has occurred, ex. StackOverflowError, OutOfMemoryError, VirtualMachineError; errors are unchecked, and program should not try to catch/handle them. Errors happen at runtime and cannot be recovered
Checked vs. unchecked exceptions
checked exceptions are verified at compile-time, ex. IOException, SQLException, ParseException. Unchecked exceptions are are exceptions in the program logic itself, and is not verified at compile-time. The exception is thrown at runtime. Ex. NullPointerException, ArrayIndexOutOfBoundsException, and IllegalArgumentException
Exception Handling and Defensive Programming
In general you want to handle exceptions with try/catch, try/catch/finally, or try-with-resources. You can also check if a value is null to guard against the NullPointerException