nerdexam
Oracle

1Z0-809 · Question #268

Given the code fragments: class ThreadRunner implements Runnable { public void run () { System.out.print ("Runnable"); } } class ThreadCaller implements Callable { public String call () throws…

The correct answer is D. es.submit(r1); Future<String> f1 = es.submit (c1). You've hit your session limit · resets 5:20pm (America/New_York)

Question

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?

Options

  • AFuture<String> f1 = (Future<String>) es.submit (r1); es.execute (c1);
  • Bes.execute (r1); Future<String> f1 = es.execute(c1);
  • CFuture<String> f1 = (Future<String>) es.execute(r1); Future<String> f2 = (Future<String>) es.execute(c1);
  • Des.submit(r1); Future<String> f1 = es.submit (c1);

How the community answered

(33 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    9% (3)
  • D
    85% (28)

Explanation

You've hit your session limit · resets 5:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice