Q42: What are the differences between Runnable and Callable interfaces?

  • Runnable: public void run(). Cannot return a result value; cannot throw checked exceptions.
  • Callable<V>: public V call() throws Exception. Returns a generic result V; allowed to throw checked exceptions. Used with ExecutorService and Future.
Key Takeaways
  • Runnable: Returns void, handles no checked exceptions. Callable: Returns generic value V, throws checked exceptions.
Knowledge Check

Which interface should be used for background asynchronous tasks that MUST return a calculation result?