← All 1Z0-819 Flashcard Decks

I/O Operations 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 I/O Operations flashcards as text
  1. Which class is used for high-performance binary file I/O using memory-mapped files in Java NIO?

    Answer: MappedByteBuffer

    `MappedByteBuffer` maps a region of a file directly into memory, enabling fast random access without traditional read/write calls.

  2. What is the purpose of `FileChannel.transferTo(position, count, target)`?

    Answer: Efficiently transfers bytes from one channel to another, potentially using OS-level zero-copy

    `transferTo` can leverage OS zero-copy mechanisms to move data between channels without buffering in the JVM heap.

  3. Which interface must be implemented to receive notifications from a `WatchService`?

    Answer: No interface — you poll `WatchKey` events from the service

    `WatchService` is poll-based: you call `take()` or `poll()` on the service to retrieve `WatchKey` objects containing `WatchEvent` lists.

  4. What does `Serializable` marker interface indicate for Java I/O?

    Answer: The class can be serialized by `ObjectOutputStream` and deserialized by `ObjectInputStream`

    Implementing `Serializable` signals that `ObjectOutputStream`/`ObjectInputStream` may serialize and deserialize instances of the class.

  5. What is the role of `serialVersionUID` in serialization?

    Answer: It is used to verify that the sender and receiver of a serialized object have loaded classes that are compatible

    During deserialization, the JVM compares `serialVersionUID` between the class definition and the stream; a mismatch throws `InvalidClassException`.

  6. Which keyword prevents a field from being serialized by `ObjectOutputStream`?

    Answer: transient

    Fields marked `transient` are skipped by the default serialization mechanism and restored to their default values on deserialization.

  7. What does `Console.readPassword()` return that makes it preferable to `readLine()` for passwords?

    Answer: A `char[]` that can be zeroed out after use, unlike `String` which is immutable

    Returning `char[]` allows the caller to overwrite the array in memory after use, while `String` values persist in the string pool.