Page 1 of 1

About Question enthuware.ocpjp.v8.2.1811 :

Posted: Fri Dec 04, 2015 7:10 am
by mrmuiz
Option 2 and 4 are both correct answers. Question is "which instruction will cause file to be written", and both of them will do the job (even though "bfw.close();" is a cleaner solution)

Re: About Question enthuware.ocpjp.v8.2.1811 :

Posted: Fri Dec 04, 2015 8:35 pm
by admin
Actually, the question is, "Which of the following lines is required to be inserted...." A call to close() is required but a call to flush() is not.

HTH,
Paul.

Re: About Question enthuware.ocpjp.v8.2.1811 :

Posted: Sun Dec 06, 2015 6:30 am
by mrmuiz
Uhm, I don't agree 100%, sentence is "Which of the following lines is required to be inserted[...]so that content in b.java will be overwritten...".

It's like asking which method will cause a transaction to be committed: "commit" is righter than "setAutocommit(true)", but both do what's asked.

But I have to admit that I've experienced borderline questions like these in the exam

Re: About Question enthuware.ocpjp.v8.2.1811 :

Posted: Wed Jan 19, 2022 12:04 pm
by sijucm
I guess the content will not be overwritten with contents in a.java. Technically because it will not add the new line characters.Of course that does not change the answer.

Re: About Question enthuware.ocpjp.v8.2.1811 :

Posted: Mon Jul 18, 2022 1:30 am
by basileu1
Hi,
Are we certain close() calls flush() behind the scene in every situation? I seem to find contradictory information while searching on this topic.
Thank you!

Re: About Question enthuware.ocpjp.v8.2.1811 :

Posted: Mon Jul 18, 2022 2:55 am
by admin
Well, the JavaDoc description of BufferedWriter clearly says that close flushes the stream. Where did you find contradictory information?

Re: About Question enthuware.ocpjp.v8.2.1811 :

Posted: Sat Jan 21, 2023 12:33 pm
by edufin166@yahoo.com
Why BufferedReader was not closed, as well? if it has the method .close()"Closes the stream and releases any system resources associated with it."
See that: https://docs.oracle.com/javase/8/docs/a ... ml#close--

Re: About Question enthuware.ocpjp.v8.2.1811 :

Posted: Sun Jan 22, 2023 1:17 am
by admin
While it is a good idea to close the BufferedReader object as well, it is has no impact on the writing part, which is done using BufferedWriter. In other words, it is irrelevant for the situation given in the problem statement.