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
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.
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.
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.
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.
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.
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.
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.