โ† All 1Z0-819 Flashcard Decks

Exception Handling & Concurrency Flashcards

7 cards from real 1Z0-819 practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Exception Handling & Concurrency flashcards as text
  1. Which method of ExecutorService blocks until all submitted tasks complete or a timeout occurs?

    Answer: awaitTermination(long, TimeUnit)

    awaitTermination() blocks the calling thread until the executor terminates or the specified timeout elapses, returning a boolean result.

  2. What kind of exception is java.io.IOException?

    Answer: Checked exception

    IOException extends Exception (not RuntimeException), making it a checked exception that must be declared or handled.

  3. What does Callable differ from Runnable in terms of return value and exceptions?

    Answer: Callable returns a typed value and can throw checked exceptions

    Callable defines call() which returns V and declares throws Exception, unlike Runnable's run() which returns void and cannot throw checked exceptions.

  4. Which exception is thrown by BlockingQueue.take() when the current thread is interrupted?

    Answer: InterruptedException

    BlockingQueue.take() blocks until an element is available and throws InterruptedException if the thread is interrupted while waiting.

  5. In a multi-catch block 'catch (IOException | SQLException e)', what is the type of 'e'?

    Answer: A union type that can only be rethrown

    In a multi-catch, the variable is implicitly final and typed as the union; it can only be rethrown as-is, not reassigned.

  6. What is a race condition?

    Answer: When program output depends on unpredictable relative timing of threads

    A race condition occurs when correctness depends on the relative execution order of concurrent threads, which is non-deterministic.

  7. Which atomic class provides a compareAndSet(expected, update) method for lock-free integer updates?

    Answer: AtomicInteger

    AtomicInteger in java.util.concurrent.atomic provides compareAndSet() (CAS) for lock-free, thread-safe integer manipulation.