Oracle
1Z0-809 · Question #25
Given the code fragment: class CallerThread implements Callable<String> { String str; public CallerThread(String s) {this.str=s;} public String call() throws Exception { return str.concat("Call"); }…
The correct answer is B. The program prints CallCall and does not terminate. You've hit your session limit · resets 5:20pm (America/New_York)
Question
Given the code fragment:
class CallerThread implements Callable<String> {
String str;
public CallerThread(String s) {this.str=s;}
public String call() throws Exception {
return str.concat("Call");
}
}
public static void main (String[] args) throws InterruptedException,
ExecutionException
{
ExecutorService es = Executors.newFixedThreadPool(4); //line n1
Future fl = es.submit (new CallerThread("Call"));
String str = fl.get().toString();
System.out.println(str);
}
Which statement is true?
Options
- AThe program prints Call Call and terminates.
- BThe program prints CallCall and does not terminate.
- CA compilation error occurs at line n1.
- DAn ExecutionException is thrown at run time.
How the community answered
(41 responses)- A5% (2)
- B76% (31)
- C12% (5)
- D7% (3)
Explanation
You've hit your session limit · resets 5:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.