โ† All SCJP Flashcard Decks

Exception Handling and Java I/O Flashcards

7 cards from real SCJP 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 and Java I/O flashcards as text
  1. Which statement about checked exceptions is correct?

    Answer: They must be caught or declared in the method signature using throws

    Checked exceptions must either be handled with a try-catch or declared with the throws keyword in the method signature.

  2. Which class should you use to efficiently write characters to a file using a buffer?

    Answer: BufferedWriter

    BufferedWriter wraps a Writer and uses an internal buffer to reduce I/O operations, improving performance.

  3. What does the try-with-resources statement require of the resources it manages?

    Answer: They must implement AutoCloseable

    Resources used in try-with-resources must implement the AutoCloseable interface so close() can be called automatically.

  4. Which exception is thrown when the JVM cannot find the definition of a class that is referenced at runtime?

    Answer: NoClassDefFoundError

    NoClassDefFoundError is thrown when a class was present at compile time but cannot be found at runtime.

  5. What is the purpose of the ObjectOutputStream class?

    Answer: To serialize Java objects to an output stream

    ObjectOutputStream serializes Java objects (that implement Serializable) by writing them as a byte stream.

  6. Which of the following exceptions is an unchecked exception?

    Answer: NullPointerException

    NullPointerException extends RuntimeException, making it unchecked; the compiler does not require it to be caught or declared.

  7. When multiple exceptions are caught in a single catch block using multi-catch (Java 7+), which statement is true?

    Answer: The caught exception variable is effectively final

    In a multi-catch block, the exception parameter is implicitly final and cannot be reassigned.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy