Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 125

Which statement is true?

    Correct Answer: A

    PrintWriter is a class in Java designed for writing characters to text-output streams. It includes an option to automatically flush the stream, which can be enabled using a constructor argument. While it does not always flush automatically by default, it can be configured to do so, fulfilling the conditions of the statement given in the option.

Discussion
ASPushkinOption: A

A right a text-output stream. automatic flushing is enabled B. fail it can have registered shutdown hooks (threads) C password is not encrypted it just suppresses echoing, so the password is not visible on the user's screen. D. Fail a text-output stream.

cathDevOption: A

A. PrintWriter: It is used for writing text data to a character stream. It automatically flushes the stream after writing, ensuring that the data is immediately sent to the output destination.

d7bb0b2Option: A

PrintWriter has methods that allow character output. Additionally, PrintWriter has an option for auto-flushing that can be enabled in the builder. When enabled, certain write and println methods will automatically flush the output buffer.

d7bb0b2Option: A

The correct answer is A. PrintWriter outputs characters and automatically flushes the stream. Explanation: A. PrintWriter is a class in Java that outputs characters to an output stream and automatically flushes the stream when a newline character is written, when the println method is invoked, or when a carriage return character is written. B. System.exit() does not invoke the close() method for the InputStream/OutputStream resources. It terminates the currently running Java Virtual Machine (JVM). It's the responsibility of your code to close streams before exiting. C. Console.readPassword() does not encrypt the text entered. It simply disables echoing, so the password is not displayed on the console when it's entered. D. PrintStream does not output only bytes. It can output all primitive data types and strings using its print and println methods.

OmnisumemOption: D

Retested. C is not true. So: D is my choice.

OmnisumemOption: C

I would vote for D. Because it is fact: "All characters printed by a PrintStream are converted into bytes using the platform's default character encoding." As regards A: "... if automatic flushing is enabled ..." so it is not true always. B is not true. So I vote for C - Tested (https://www.geeksforgeeks.org/console-readpassword-method-in-java-with-examples/).

[Removed]Option: A

I find this a rather tricky one because and would like to know the answer. So what I found is that a PrintWriter doesn't automatically flushes the stream, it does however have a constructor accepting a boolean to ENABLE autoflushing.. for D.. I found this in the oracle docs: All characters printed by a PrintStream are converted into bytes using the platform's default character encoding. The PrintWriter class should be used in situations that require writing characters rather than bytes. So it's either A or D

[Removed]

To be fair I would answer D over A on the actual exam. As autoflushing is clearly not AUTOMATICALLY enabled.

StavokOption: A

It has a constructor that can take an OutputStream as an argument, and an optional second argument that specifies whether the stream should be automatically flushed when println is called. This means that the data is immediately written to the underlying output stream, instead of being buffered.

belal97Option: B

Which is correct ?? i think A is false !!