About Question enthuware.ocpjp.v7.2.1090 :
Moderator: admin
-
- Posts: 33
- Joined: Mon May 06, 2013 9:41 am
- Contact:
About Question enthuware.ocpjp.v7.2.1090 :
Maybe it's just me, but for me the third option (with BufferedOutputStream) produces a zero length file
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
The code for //close open streams is not shown but you should always flush a buffered stream before closing.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 12
- Joined: Thu Dec 11, 2014 12:32 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
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
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
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
Why do you think so?
If you like our products and services, please help us by posting your review here.
-
- Posts: 12
- Joined: Thu Dec 11, 2014 12:32 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
because i use same object type reference that is:
DataOutputStream XXX
DataOutputStream XXX
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
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.
-
- Posts: 5
- Joined: Fri Jan 15, 2016 8:49 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
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?
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?
-
- Posts: 23
- Joined: Sun Feb 21, 2016 10:12 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
I also have the same question. Are those topics are in syllabus in details?
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
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.
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.
-
- Posts: 1
- Joined: Thu Nov 26, 2020 6:13 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
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.
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.
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1090 :
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.
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.
Who is online
Users browsing this forum: No registered users and 17 guests