Question 179 / 297:  What is the output of compiling and running the following code?
public class Test extends Thread {

static int count = 0;

public static void main(String argv[]) {

Test t = new Test ();

t.increment(count);

t.start();

Thread.sleep(1000);

System.out.println(count);

}

public void increment(int count) {

++count;

}

public void run() {

count = count + 5;

}

}

A  5
B  6
C  Compilation error
<< First < Previous Next > Last >>
Explanation:

Thread.sleep(1000) throws a checked exception (InterruptedException) which must be handled by either a try/catch block or by declaring it in the header of main() method

Exam Home Page
Ask
Madison Christian
Start Exam
Jugnu Khan
Start Quiz
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>