Oracle
1Z0-829 · Question #3
1Z0-829 Question #3: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #3. The question stem and answer options stay visible for context.
Question
Given the code fragment:
ExecutorService executorService = Executors.newSingleThreadExecutor();
Set<Callable<String>> workers = new HashSet<Callable<String>>();
workers.add(new Callable<String>() {
public String call() throws Exception {
return "1";
}
});
workers.add(new Callable<String>() {
public String call() throws Exception {
return "2";
}
});
workers.add(new Callable<String>() {
public String call() throws Exception {
return "3";
}
});
Which code fragment invokes all callable objects in the workers set?
Options
- AList<Future<String>> futures = executorService.invokeAny(workers); for(Future<String> future : futures){ System.out.println(future.get()); }
- BexecutorService.submit(cThreads);
- CList<Future<String>> futures = executorService.invokeAll(workers); for(Future<String> future : futures){ System.out.println(future.get()); }
- Dfor (int i=0; i<3;i++){ String result = executorService.invokeAny(cThreads); System.out.println(result); }
Unlock 1Z0-829 to see the answer
You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.