my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes IO Quetion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "IO Quetion" Watch "IO Quetion" New topic
Author

IO Quetion

ricky gonzalez
Ranch Hand

Joined: Jun 30, 2000
Posts: 167
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Jul 23, 2000
Posts: 14
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: IO Quetion
 
Similar Threads
OutputStream question
www.valoxo.ch mock01a.html Q12
write(0x01234567)
Answer please
character coding problem