• 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

Reg. RandomAccessFile

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is a question on IO from JavaCaps mock exam#1 :

The correct answer is B)
I am not clear as to how the data will be stored, and how
the seek will locate position 5. I know that seek
is used to the next read operation and starts from index 0.
Can some one explain to me .
Thanks a lot
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The seek() method works in bytes. The boolean value at the start will take up 1 byte (even though a boolean is actually only 1 bit long) at position 0, then the first int will take up the next 4 bytes (postions 1,2,3 and 4). Position 5 would be the first byte of the second int and hence the second int is displayed.
Regards,
Richard
 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Richard.

reply
    Bookmark Topic Watch Topic
  • New Topic