Error and Exception in java are very common in java programming. Most of the time exception are caused by our program and programmer can handle it using exception handling.
A Java Exception is an object that describes the exception that occurs in a program. When any exception occurs during execution of the java program
then this exception must be thrown either by JRE or Java Programmer. The code which responsible exception handling is called an exception handler.
So in Java Exceptions are those runtime errors which program can handle it using try and catch block. These exceptions can be language define exception or
programmer define business exception.
What is Error?
Error is also an exception which comes at runtime in java program. But error can not be handled since this comes
if enough resources are not there or some important classes are missing(not in classpath) at runtime. if program writes try and catch to handle this kind of error then it does not make sense. Errors are also unchecked exception.
Example :- If OutOfMemoryError occurs then program will terminate abnormally since we cannot increase memory at runtime.
Other Examples : NoClassDefFoundError, VirtualMachineError, IncompatibleClassChangeError, UnsatisfiedLinkError etc.