4 Difference between NoClassDefFoundError and ClassNotFoundException

In this tutorial , we will understand the difference between NoClassDefFoundError  and ClassNotFoundException. This is one of the questions to increase the knowledge of java exceptions.
We have already shared the

We will look into the differences , similarities and examples of NoClassDefFoundError and ClassNotFoundException.


Difference between NoClassDefFoundError and ClassNotFoundException

Error vs Exception :  The major difference is in their names. You see that NoClassDefFoundError is Error and derived from LinkageError. It means that NoClassDefFoundError occurs during linking and program can’t run, but compiles successfully.
ClassNotFoundException is Exception and derived from ReflectiveOperationException
It occurs during runtime
Irrecoverable vs recoverable:  NoClassDefFoundError refers irrecoverable situation that are not being handled by try/catch/finally block. ClassNotFoundException is checked exception, which requires handling using try/catch/finally block.

Difference between Yield and Sleep method in Java with Example

We have already shared the difference between Wait and sleep method in java and difference between extends thread and implements runnable. In this article we will see the difference between sleep and yield method in java. This question is related to the topic concurrency. According to  Oracle docs we will discuss the differences , similarities and example of Sleep and Yield method.


Read Also :  LifeCycle of Thread in  Java 


Difference between  Yield and Sleep method in Java with Example

1. Currently executing thread state : Sleep  method causes the currently executing thread to sleep for the number of milliseconds or the  nanoseconds specified in the argument.

There are two overloaded sleep methods

sleep (long milliseconds) , takes milliseconds as an argument.
and
sleep (long milliseconds , int nanoseconds) specifies milliseconds and nanoseconds as an argument.

According to Oracle docs,
Yield method temporarily pauses the currently executing thread to give a chance to the remaining waiting threads of the same priority to execute.
If there is no waiting thread or all the waiting threads of low priority then the current thread will continue its execution.


2. Interrupted Exception : Sleep method throws the Interrupted exception if another thread