Java SE 11 Developer (1Z0-819) — Question 131
Which statement is true?
Answer options
- A. PrintWriter outputs characters and automatically flushes the stream.
- B. System.exit() invokes the close() method for the InputStream/OutputStream resources.
- C. Console.readPassword() method encrypts the text entered.
- D. PrintStream outputs only bytes.
Correct answer: A
Explanation
Option A is correct because PrintWriter is designed to handle characters and includes automatic flushing capabilities. Option B is incorrect as System.exit() does not call close() on streams; it simply terminates the Java Virtual Machine. Option C is misleading; while Console.readPassword() obscures the input, it does not encrypt it. Option D is incorrect because PrintStream can handle both bytes and characters.