Given a sample code:
public class Test3 {
public static void main(String args[]) {
Test1 pm1 = new Test1("Hi");
pm1.run();
Test1 pm2 = new Test1("Hello");
pm2.run();
}
}
class Test1 extends Thread {
private String sTname = "";
Test1(String s) {
sTname = s;
}
public void run() {
for (int i = 0; i < 2; i++) {
try {
sleep(1000);
} catch (InterruptedException e) {
}
yield();
System.out.println(sTname);
}
}}
Which of the following statement is correct ?
(A) Compilation error
(B) Hi Hi Hello Hello
(C) Hi Hello Hi Hello
(D) Hi Hello
(B)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.