About Question enthuware.ocpjp.v8.2.1905 :

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

Moderator: admin

Post Reply
__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

About Question enthuware.ocpjp.v8.2.1905 :

Post by __JJ__ »

Sorry, I'm just trying to figure out what this question is testing.
What are the implications of the information in the question?

In my tests if I do pw.write(99) I get a file with a c in it. Hex value of c is 63. OK, not very interesting to me, what's the significance of that?

If I do fos.write(99) I get exactly the same result in the file ie hex 63 = 'c'.

I'm just wondering what the use of the information in the question is and what concept exactly is being tested.

Thanks.

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

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

Post by admin »

The question is about the size of the argument and the number of bytes written to the file. They are not always the same. For example, an int is of 4 bytes, but only 1 byte is written to the file. Please read the explanations given with the options.

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

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

Post by __JJ__ »

So this question could be..."when is an int an int and when is it not an int...."
I suppose if one were writing a billion ints to a file this would be a useful concept to know.

Thank you anyway.

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

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

Post by admin »

Not really. It is actually very important to know even if you are writing just one int. What if the value of the int that you pass to the method is larger than 127 ?

bvrulez
Posts: 33
Joined: Sat Feb 15, 2020 12:44 am
Contact:

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

Post by bvrulez »

OutputStream and BufferedOutputStream
- write(int): writes the int, but just 8 bits

DataOutputStream
- writeInt(): Use this to write the complete stuff
- ALSO: writeChar(), writeDouble(), readInt()...

PrintWriter(of OutputStream or BufferedOutputStream)
- write(int): writes the Stringrespresentation as Character, not the int, size depending on platform default (encoding)

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests