Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Answers for OCJP / SCJP Online Test | Mock Test

←Go Back to Online Practice Test

Ques.

1. class A implements Runnable {
2.     public void run() {
3.         try {
4.             Thread.sleep(1000*5);
5.             // insert code
6.         }
7.      }
8. }

 

public class Test { 
    public static void main(String... args) {
        A a = new A();
        Thread t = new Thread(a);
        t.setName("good");
        t.start();
    }
}


Which of the following code to be inserted at line no 5 to compile without error?


Option 1.

}catch(InterruptedException e){

Option 2.

}catch(IOException e){

Option 3.

}catch(ThreadException e){

Option 4.

}catch(IllegalThreadStateException e){


Ans. Option 1

Please provide the reason below. The best provided reason will be displayed with your name(if you are logged-in) on website.
Enter Reason
 
Is it helpful? Yes No
©2024 WithoutBook