Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


What must be implemented for a class to execute a task that returns a result after completion?

  1. Runnable

  2. Callable

  3. Executor

  4. Futures

The correct answer is: Callable

A and C are incorrect because they do not return a result after completion. A Runnable does not return a value and an Executor is used to manage and execute threads, not tasks that return a result. D is not the best answer because Futures alone cannot implement a task, it is a mechanism for asynchronously retrieving results from a concurrent task. Callable is the closest match to what the question is asking for.