โ† 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. What happens when both the try block and the finally block throw exceptions?

    Answer: The finally block's exception propagates and the try block's exception is lost

    The exception thrown in the finally block replaces the one from the try block, causing the original exception to be silently lost.

  2. Which interface must a class implement to be used as the target of a Thread?

    Answer: Runnable

    The Runnable functional interface (with its run() method) is the standard contract for thread task targets.

  3. What does ReentrantLock.tryLock() return if the lock is already held by another thread?

    Answer: It returns false immediately

    tryLock() is a non-blocking acquire attempt that returns false immediately if the lock cannot be obtained.

  4. Which exception is thrown when a thread is interrupted while waiting in Object.wait()?

    Answer: InterruptedException

    Object.wait() declares throws InterruptedException, which is thrown when the waiting thread's interrupt status is set.

  5. What is the output of: try { throw new RuntimeException(); } catch (Exception e) { System.out.print("A"); } finally { System.out.print("B"); }

    Answer: AB

    The catch block prints 'A', then the finally block always executes and prints 'B', giving 'AB'.

  6. Which class provides a thread-safe, resizable array implementation in Java?

    Answer: CopyOnWriteArrayList

    CopyOnWriteArrayList is the modern thread-safe list that creates a fresh copy of the backing array on every mutation.

  7. What is the purpose of the volatile keyword on a variable?

    Answer: It guarantees visibility of writes across threads without caching

    volatile ensures all threads see the most recent write by bypassing CPU caches, but does not make compound operations atomic.