Question 24
|
What will be the output on compiling/running the following code? public class MyThread implements Runnable { String myString = "Yes "; public void run() { this.myString = "No "; } public static void main(String[] args) { MyThread t = new MyThread(); new Thread(t).start(); for (int i=0; i < 10; i++) System.out.print(t.myString); } }
|
||
| Compilation Error | ||
| Prints : Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes and so on. | ||
| Prints : No No No No No No No No No No and so on. | ||
| Prints : Yes No Yes No Yes No Yes No Yes No and so on. | ||
| The Output cannot be determined. | ||
Back to beginning | Next Question |
||
