Skip to content
Sharp

Java Threading interview questions

Atomic Variables, ExecutorService, Race Conditions, Synchronized and Locks, The Volatile Keyword, Virtual Threads

62 questions with answers and explanations · 62 flashcards

Questions (page 2 of 2)

  1. How does CompletableFuture help in managing asynchronous computations?Multiple choiceMedium
  2. How do Virtual Threads affect the performance of CPU-bound tasks compared to I/O-bound tasks?Multiple choiceMedium
  3. Which Java version introduced Virtual Threads as part of Project Loom?Multiple choiceEasy
  4. What happens if you call shutdownNow() on an ExecutorService?Multiple choiceMedium
  5. In which scenario would a ScheduledThreadPoolExecutor be preferred over a FixedThreadPool?Multiple choiceHard
  6. How does the JVM manage Virtual Threads during a blocking network I/O operation?Multiple choiceHard
  7. How does the ExecutorService improve task management over using raw Threads?Multiple choiceMedium
  8. What happens to tasks submitted to an ExecutorService after shutdown() is called?Multiple choiceEasy
  9. What happens when a CompletableFuture executes a task on a virtual thread?Multiple choiceHard
  10. What could be a potential downside of using a CachedThreadPool for handling a large number of short-lived tasks?Multiple choiceHard
  11. Which of the following Java constructs can be used to execute tasks using Virtual Threads?Multiple choiceMedium
  12. What does volatile actually guarantee in Java?Multiple choiceEasy