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
What is the output of `System.out.printf("%05.2f", 3.7)` ?
Answer: "03.70"
`%05.2f` formats to total width 5, 2 decimal places, zero-padded, producing `03.70`.
Which `PrintWriter` constructor automatically flushes the buffer after every `println`, `printf`, or `format` call?
Answer: Both A and C
Passing `true` as the auto-flush argument to either the `Writer` or `OutputStream` constructor enables auto-flush on line-terminating methods.
What does `DataInputStream.readUTF()` expect about the byte stream format?
Answer: A 2-byte length prefix followed by modified UTF-8 encoded bytes
`readUTF` reads a 2-byte big-endian length then the modified UTF-8 bytes, matching the format written by `DataOutputStream.writeUTF`.
Which NIO.2 attribute view provides access to POSIX file permissions?
Answer: PosixFileAttributeView
`PosixFileAttributeView` exposes owner, group, and permission bits on POSIX-compliant filesystems.
What is the default behavior of `Files.copy(InputStream in, Path target)` if the target file already exists?
Answer: It throws `FileAlreadyExistsException`
Without `REPLACE_EXISTING`, `Files.copy` fails with `FileAlreadyExistsException` to avoid silent data loss.
Which method on `BufferedWriter` writes a platform-dependent newline?
Answer: newLine()
`BufferedWriter.newLine()` writes the system property `line.separator`, making output portable across platforms.
What does calling `mark(readAheadLimit)` on a `BufferedInputStream` allow you to do?
Answer: Reset the stream position back to the marked point after reading up to `readAheadLimit` bytes
`mark` saves the current position; `reset` returns to it as long as no more than `readAheadLimit` bytes have been read since the mark.