About Question enthuware.ocpjp.v7.2.1090 :

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

Moderator: admin

Post Reply
bptoth
Posts: 33
Joined: Mon May 06, 2013 9:41 am
Contact:

About Question enthuware.ocpjp.v7.2.1090 :

Post by bptoth »

Maybe it's just me, but for me the third option (with BufferedOutputStream) produces a zero length file :?:

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

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by admin »

The code for //close open streams is not shown but you should always flush a buffered stream before closing.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

rocky_bgta
Posts: 12
Joined: Thu Dec 11, 2014 12:32 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by rocky_bgta »

1)DataOutputStream dos = new DataOutputStream(os);
dos.write(1);
A file of size 4 bytes will be created.

2)os.write(1);
A file of size 1 byte will be created.

3)BufferedOutputStream bos = new BufferedOutputStream(os);
DataOutputStream dos = new DataOutputStream(bos);
dos.write(1);
A file of size 1 byte will be created.

4)os.writeInt(1);
A file of size 4 bytes will be created.

Answer say option 2 and 3 are correct answer, But my question if option 3 is correct then option 1 should also correct.
Please explain me.
Thanks

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

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by admin »

Why do you think so?
If you like our products and services, please help us by posting your review here.

rocky_bgta
Posts: 12
Joined: Thu Dec 11, 2014 12:32 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by rocky_bgta »

because i use same object type reference that is:
DataOutputStream XXX

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

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by admin »

Right, since both are using DataOutputStream, you cannot have file size of 4 bytes in one and 1 byte in another. Both cannot be correct.
If you like our products and services, please help us by posting your review here.

rianne
Posts: 5
Joined: Fri Jan 15, 2016 8:49 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by rianne »

I've got a completely different question:
The book I am using to study for the exams, clearly states that you only have to know Reader and Writer classes/methods for the exam, and that if you see Streams, the question will be about serialization...
(I am using the OCA/OCP Java SE7 Programmer I & II Study Guide by Kathy Sierra and Bert Bates)
Then why are there questions like this in the mock exams? Is my book wrong?

sumanenthu
Posts: 23
Joined: Sun Feb 21, 2016 10:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by sumanenthu »

I also have the same question. Are those topics are in syllabus in details?

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

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by admin »

We add questions to our question bank on such topics only because some candidates have reported getting question on such topics.
The real exam is quite dynamic and they change their questions often. We keep an eye on feedback from candidates who take the exam and make changes to our question bank accordingly.

I can't really comment on any particular but but it is a fact that books are static. They can't be changed once they are printed and that is why they cannot track the changes in the exam as well as we can.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

FiskSMK
Posts: 1
Joined: Thu Nov 26, 2020 6:13 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by FiskSMK »

Response 4 seems having error in explanation:

os.writeInt(99);
A file of size 4 bytes will be created.
OutputStream does not provide methods for writing primitives.
It writes bytes only. Therefore, this will not compile.

We have write(int b). Valid explanation would there is no such method.

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

Re: About Question enthuware.ocpjp.v7.2.1090 :

Post by admin »

The explanation is talking about methods such as writeInt, writeChar, writeBoolean etc.
The write(int b) method does not write an int to the file. It writes only the byte part of the int.

The explanation has now been enhanced to make it clear.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests