Instructions Use the Java API htt docs oraclecom avase8docsa
Solution
11 Ans) InterruptedException is one of checked exception that does not inherit from IOException. It is directly inherited from Exception class.
12 Ans) InterruptedException is thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity. Below is the example when it will be thrown:-
public class Project4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
try {
Thread.sleep(900);
} catch (InterruptedException ex) {
Logger.getLogger(Project4.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
13 Ans) Checked Exceptions are exceptions that are checked at compile time. If some code in a method throws checked exception , then that method should handle that exception by using try-catch clause or add throws clause to method declaration. Unchecked Exceptions are exceptions that are not checked at compile time. So even if your code does not handle the exception compiler does not force you to handle the exception.
