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 statement about the Error class hierarchy is correct?
Answer: Error extends Throwable directly
Error extends Throwable directly (not Exception), and errors like OutOfMemoryError and StackOverflowError represent serious JVM-level problems.
What does CountDownLatch.await() do when the count reaches zero?
Answer: It unblocks all waiting threads
When countDown() reduces the latch's count to zero, all threads blocked on await() are released simultaneously.
Which exception is thrown when you call Future.get() on a cancelled task?
Answer: CancellationException
Calling get() on a Future that was cancelled via cancel(true) causes CancellationException to be thrown.
What is the effect of calling Thread.interrupt() on a thread that is currently sleeping?
Answer: The thread's sleep is interrupted and InterruptedException is thrown
Interrupting a sleeping thread causes the sleep to terminate early by throwing InterruptedException and clearing the thread's interrupt status.
Which method of Semaphore acquires a permit, blocking until one is available?
Answer: Semaphore.acquire()
Semaphore.acquire() decrements the permit count, blocking if no permits are available until another thread calls release().
What is the behavior of a FixedThreadPool created with Executors.newFixedThreadPool(3) when a 4th task is submitted while all 3 threads are busy?
Answer: The task is queued in an unbounded LinkedBlockingQueue
newFixedThreadPool uses an unbounded LinkedBlockingQueue, so excess tasks wait in the queue rather than being rejected or creating new threads.
Which exception type should you catch to handle both IOException and RuntimeException in a single catch block without multi-catch syntax?
Answer: Exception
Both IOException and RuntimeException extend Exception, so catching Exception covers both, though it also catches other exception subtypes.