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.
About Question enthuware.ocpjp.v8.2.1905 :
Moderator: admin
-
- Posts: 125
- Joined: Thu Jul 05, 2018 6:44 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1905 :
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.
-
- Posts: 125
- Joined: Thu Jul 05, 2018 6:44 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1905 :
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.
I suppose if one were writing a billion ints to a file this would be a useful concept to know.
Thank you anyway.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1905 :
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 ?
-
- Posts: 33
- Joined: Sat Feb 15, 2020 12:44 am
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1905 :
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)
- 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)
Who is online
Users browsing this forum: No registered users and 4 guests