between NoClassDefFoundError and ClassNotFoundException
comes when Java runtime fails to find a class at runtime, even though
it was present at compile time. This could happen if some class was
compiled but while creating a jar/war, it got left out. So the error
came when Java tried to load that class during runtime.
comes when a class is attempted to be loaded by its name given as a
string to methods like
the NCDFError is non-recoverable as it interferes directly with Java
virtual machine and one cannot be caught with try-catch. But the
CNFException is a recoverable problem as its an exception and can be
caught with try-catch.
to sum up, severity of CNFException is lower than that of NCDFError
and it is recoverable by using try-catch.
for both the above is mostly the same: lookup your included jars and
classes to see which one is missing at runtime.
between Checked and Unchecked Exception
- Exceptions that capture errors caused by wrong input to
programs/methods. These exceptions are required to be specified in
the throws clause of a function and if they are specified, the
calling function must handle them appropriately using throws itself
or by using try-catch. Examples:
- These are the exceptions which arise due to faulty logic of the
program. These are not required to be specified by throws clause and
if specified, the calling function is not required to handle them.