Question 221 / 297:  What is ture?
public class Test implements Runnable {

public static void main(String[] args) throws InterruptedException {

Test test = new Test();

Thread t= new Thread(test);

t.start();

t.join();

System.out.print("main");

}

public void run() {

System.out.print("run");

}

}

A  the output could be "mainrun"
B  the output could be "runmain"
C  the output could be "run" then an exception is thrown at run time
D  compilation error
<< First < Previous Next > Last >>
Explanation:

thread.join() means that the current running thread main() should wait till thread "t" is dead and then can continue execution. Which means the only possible printed output is "runmain"

Exam Home Page
Ask
Dionne Mahaffey
Start Quiz
Megan Earhart
Start Quiz
Michael Sag
Start Exam
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>