This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg. RandomAccessFile Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Reg. RandomAccessFile" Watch "Reg. RandomAccessFile" New topic
Author

Reg. RandomAccessFile

Angela Narain
Ranch Hand

Joined: Apr 14, 2001
Posts: 327
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
Richard Barnes
Greenhorn

Joined: May 17, 2001
Posts: 6
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

Joined: Apr 14, 2001
Posts: 327
Thanks Richard.

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Reg. RandomAccessFile
 
Similar Threads
about file class
RandomAccessFile question
RAF question from javacaps mock, help requested
io--seek()
i/o question any help