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 interface do you implement for a class to fulfill a task but not return any value?

  1. Callable

  2. Executors

  3. Runnable

  4. Thread

The correct answer is: Runnable

The correct interface to implement for a class to execute a task but not return a value is the Runnable interface. Option A, Callable, is incorrect because it is used when a value needs to be returned. Option B, Executors, is incorrect because it is a class that provides static utility methods for executing tasks. Option D, Thread, is incorrect because it is a class rather than an interface.