exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 161 discussion

Actual exam question from Oracle's 1z0-809
Question #: 161
Topic #: 1
[All 1z0-809 Questions]

Given the code fragments:
class ThreadRunner implements Runnable {
public void run () { System.out.print ("Runnable") ; }
}
class ThreadCaller implements Callable {
Public String call () throws Exception {return "Callable"; )
}
and
ExecutorService es = Executors.newCachedThreadPool ();
Runnable r1 = new ThreadRunner ();
Callable c1 = new ThreadCaller ();
// line n1
es.shutdown();
Which code fragment can be inserted at line n1 to start r1 and c1 threads?

  • A. Future<String> f1 = (Future<String>) es.submit (r1); es.execute (c1);
  • B. es.execute (r1); Future<String> f1 = es.execute (c1) ;
  • C. Future<String> f1 = (Future<String>) es.execute(r1); Future<String> f2 = (Future<String>) es.execute(c1);
  • D. es.submit(r1); Future<String> f1 = es.submit (c1);
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
steefaand
5 months, 4 weeks ago
Selected Answer: D
D is true. Execute method accepts only Runnable, not Callable.
upvoted 1 times
...
duydn
10 months, 2 weeks ago
Selected Answer: D
Runnable return void Callable can return a type -> D is correct
upvoted 1 times
...
Svetleto13
3 years, 2 months ago
D,tested.It prints Runnable
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago