• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Output Stream

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
Q) If write(0x01234567) is called on an instance of OutputStream what will be written to the destination of stream
A) byte 0x67
Can somebody outline the steps to compute the answer?
Another thing is does exam really test us on such heavy questions ??

Thanx
Kaushik
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quote
-----------------
Q) If write(0x01234567) is called on an instance of OutputStream what will be written to the destination of stream
A) byte 0x67
Can somebody outline the steps to compute the answer?
Another thing is does exam really test us on such heavy questions ??
---------------------------
Hello.. relax. This is not a tough question.
It is better if u get such questions.
Lets goto the problem.
write returns a byte.
u are passing an integer which is havin 4 bytes length.
Now after writing the lower most byte everything else is out. i.e., Not there & hence the result.
There are a few practice questions in a few of mocks.
Also try Khalid book
HTH
tvs sundaram
 
Kaushik Badiyani
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by tvs sundaram:
Quote
-----------------
Q) If write(0x01234567) is called on an instance of OutputStream what will be written to the destination of stream
A) byte 0x67
Can somebody outline the steps to compute the answer?
Another thing is does exam really test us on such heavy questions ??



I know that write takes int as an parameter and returns byte
But how do we calcutate it... I mean i do need to convert hex to integer and then calculate its Binary Value!! Right
Wont this converting take a long time!!!
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I mean i do need to convert hex to integer and then calculate its Binary Value!! Right


no need to take all that trouble my friend !!!
let's get it step by step
1. 0x01234567 - this is the hexadecimal representation of the number that we are taking into consideration
2. we also know that this integer occupies 32 bits i.e 4 bytes
so lets split it
byte 1 - 67
byte 2 - 45
byte 3 - 23
byte 4 - 01
3. now since the write method takes an int and returns a byte we only need to take into consideration byte 1 i.e 67
hope its clear now
Samith.P.Nambiar

 
reply
    Bookmark Topic Watch Topic
  • New Topic