What is the primary difference between Runnable and Callable interfaces?
- Callable can be scheduled for future execution.
- Callable can run without being wrapped in a thread.
- Runnable allows returning a result.
- Runnable can be used for multi-threading.
The primary difference between Runnable and Callable interfaces is that Callable allows you to return a result from the computation, whereas Runnable does not. Callable is typically used when you need a result from a task that can be scheduled for future execution, while Runnable is a simple interface for a task that does not return a result.
Loading...
Related Quiz
- What will be the output of the following code snippet: System.out.println(10 + 20 + "Hello" + 30 + 40);?
- Using the ________ method, you can run multiple SQL statements using a single Statement object, separated by semicolons.
- Which of the following sorting algorithms is most efficient in terms of average-case time complexity?
- Which keyword is used in Java to test a condition?
- How is the default constructor related to constructor overloading?