Originally posted by Arun Mishra:
Hi,
The right answer is [c] but I think it should be [d]. Please help me to understand this problem.
Thanks,
Arun
Imagine a file that is 10 bytes long. When you create a RandomAccessFile object, the file pointer points to position 0, immediately before the first byte of the file. Now, if you call length, it will return the value 10 (since length returns the length of the file in bytes). If you send that value to seek, it will move the pointer 10 bytes forward, which puts it one
before the final byte, because the pointer originally started one
before the first byte. The key is that the value seek moves to is measured from the beginning of the file, which is position 0.
I hope this helps.
Corey