About Question enthuware.ocpjp.v8.2.1811 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
mrmuiz
Posts: 49
Joined: Mon Jul 27, 2015 4:34 am
Contact:

About Question enthuware.ocpjp.v8.2.1811 :

Post 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)

admin
Site Admin
Posts: 9802
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

mrmuiz
Posts: 49
Joined: Mon Jul 27, 2015 4:34 am
Contact:

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

Post 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

sijucm
Posts: 8
Joined: Tue Jan 11, 2022 4:41 am

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

Post 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.

basileu1
Posts: 2
Joined: Tue Aug 10, 2021 8:37 am
Contact:

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

Post 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!

admin
Site Admin
Posts: 9802
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Well, the JavaDoc description of BufferedWriter clearly says that close flushes the stream. Where did you find contradictory information?
If you like our products and services, please help us by posting your review here.

edufin166@yahoo.com
Posts: 13
Joined: Wed Sep 28, 2022 9:41 am
Contact:

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

Post 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--

admin
Site Admin
Posts: 9802
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest