nerdexam
Oracle

1Z0-804 · Question #26

What are two differences between Callable and Runnable?

The correct answer is A. A Callable can return a value when executing, but a Runnable cannot. D. A Callable can throw an Exception when executing, but a Runnable cannot. The Callable interface is similar to Runnable, in that both are designed for classes whose instances arepotentially executed by another thread. A Runnable, however, does not return a result and cannot throw achecked exception.

Concurrency

Question

What are two differences between Callable and Runnable?

Options

  • AA Callable can return a value when executing, but a Runnable cannot.
  • BA Callable can be executed by a ExecutorService, but a Runnable cannot.
  • CA Callable can be passed to a Thread, but a Runnable cannot.
  • DA Callable can throw an Exception when executing, but a Runnable cannot.

How the community answered

(26 responses)
  • A
    73% (19)
  • B
    12% (3)
  • C
    15% (4)

Explanation

The Callable interface is similar to Runnable, in that both are designed for classes whose instances arepotentially executed by another thread. A Runnable, however, does not return a result and cannot throw achecked exception.

Topics

#Callable#Runnable#return value#checked exceptions

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice