Page 1 of 1

About Question enthuware.ocpjp.v8.2.1905 :

Posted: Fri Jul 27, 2018 7:56 pm
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.

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

Posted: Fri Jul 27, 2018 9:18 pm
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.

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

Posted: Sun Jul 29, 2018 6:42 am
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.

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

Posted: Sun Jul 29, 2018 10:11 am
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 ?

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

Posted: Mon Feb 24, 2020 7:54 am
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)