posted 23 years ago
Taken from appliedreasoning.com mock quest #51
Which of the following statements about java.io.RandomAccessFile are true?
A. An instance of RandomAccessFile must be created with a mode.
B. When an instance of RandomAccessFile is created with a read mode, the underlying file will be created if it does not already exist.
C. When an instance of RandomAccessFile is created with a read/write mode, the underlying file will be created if it does not already exist.
D. The RandomAccessFile implements the java.io.DataOutput and java.io.DataInput interfaces.
E. If a RandomAccessFile is opened for read on a file that does not exist the FileNotFoundException is thrown.
First off, this is a hard mock exam! The answer given for the above question is A, C, D, E. I had only A & E. I missed C because I was sure I'd read somewhere that a RandomAccessFile will throw an exception if the file it refers to does not exist regardless of whether or not it is created "rw" or "r". I'm probably wrong but can someone confirm that these answers make sense. I'm going to try it out myself but I thought I'd throw it out to all you folk to ponder as well.
Thanks ... Gerry