You have created a TimeOut class as an extension of Thread, the purpose being to print a "Time's Up" message if the Thread is not interrupted within 10 seconds of being started. Here is the run method that you have coded. 1. public void run() 2. { 3. System.out.println("Start!"); 4. try 5. { 6. Thread.sleep(10000); 7. System.out.println("Time's Up!"); 8. } 9. catch(InterruptedException e) 10. { 11. System.out.println("Interrupted!"); 12. } 13. } Given that a program creates and starts a TimeOut object, which of the following statements is true?

  1. Exactly 10 seconds after the start method is called, "Time's Up!" will be printed.

  2. Exactly 10 seconds after "Start!" is printed, "Time's Up!" will be printed.

  3. The delay between "Start!" being printed and "Time's Up!" will be 10 seconds plus or minus one tick of the system clock.

  4. If "Time's Up!" is printed you can be sure that at least 10 seconds have elapsed since "Start!" was printed.


Correct Option: D

Find more quizzes: