This is a question taken from JQuest mock exam.
Here is part of the code for a class which implements the Runnable interface.
1. public class Whiffler extends Object implements Runnable {
2.
Thread myT ;
3. public void start(){
4. myT = new Thread( this );
5. }
6. public void run(){
7. while( true ){
8. doStuff();
9. }
10. System.out.println("Exiting run");
11. }
12. // more class code
Assume that the rest of the class defines doStuff, etc and that the class compiles without error. Also assume that a
Java application creates a Whiffler object and calls the Whiffler start method, that no other direct calls to Whiffler methods are made an that the Thread in this object is the only one the application creates. Which of the following are correct statements ?
a. The doStuff method will be called repeatedly.
b. The doStuff method will never be executed.
c. The doStuff method will execute atleast one time.
d. The statement in line 10 will never be reached.
According to me 'a' is the right answer. But the correct answers are 'b' and 'd'.
Can anybody explain me why 'b' and 'd' are the correct answers.