Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IO Quetion

 
ricky gonzalez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If write(0x01234567) is called on an instance of OutputStream, what will be written to the destination of the stream?
Select the right answer.
a The bytes 0x01, 0x23, 0x34, 0x45, and 0x67, in that order.
b The bytes 0x67, 0x45, 0x34, 0x23, and 0x01, in that order.
c The byte 0x01.
d The byte 0x67.
e None of the above.

Does anyone know?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java uses what is known as "network order" - the highest byte of a multi byte integer is written first. This is the opposite of the Windows / Intel convention.
WBB
 
john shen
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
write(int b)
Writes the specified byte to this output stream.
this is what the javadoc says. this means that all but the right-most 4 bits are discarded during write. you can try it yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic