Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 73

Given the code fragment:

class CallerThread implements Callable {

String str;

public CallerThread(String s) {this.str=s;}

public String call() throws Exception {

return str.concat("Call");

}

}

and

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

{

ExecutorService es = Executors.newFixedThreadPool(4); //line n1

Future f1 = es.submit (newCallerThread("Call"));

String str = f1.get().toString();

System.out.println(str);

}

Which statement is true?

    Correct Answer: B

    The program prints Call Call and does not terminate because the ExecutorService is not shut down. This causes the program to continue running indefinitely as the thread pool remains active.

Discussion
Svetleto13Option: B

B,tested

MahdiHamdiiOption: B

The program prints Call Call and does not terminate because there isn't an es.shutdown().

WilsonKKerllOption: B

Answer is B.

asdfjhfgjuaDCVOption: B

B is the correct answer

steefaandOption: B

B is true as ExecutorService is not shut down.