Multiple Choice
Assume we have a RandomAccessFile object, file, that stores a set of records of class MyData. The size of each record is MyData.RECORD_SIZE. Assume MyData has read and write methods both of which take a RandomAccessFile as an argument. Method write writes the object at the current location. Method read reads the record from current location of the file into the object. If we are currently at the beginning of the 1st record, which code correctly modifies the 2nd record by changing its color to Color.red through the setColor method?
A) file.seek(MyData.RECORD_SIZE) ;
MyData.read(file) ;
MyData.setColor(Color.red) ;
File.seek(MyData.RECORD_SIZE) ;
MyData.write(file) ;
B) myData.read(file) ;
MyData.read(file) ;
MyData.setColor(Color.red) ;
MyData.write(file) ;
C) myData.read(file) ;
MyData.setColor(Color.red) ;
File.seek(file.getFilePointer() + MyData.RECORD_SIZE) ;
MyData.write(file) ;
D) long loc = file.getFilePointer() ;
MyData.read(file) ;
MyData.setColor(Color.red) ;
File.seek(loc) ;
MyData.write(file) ;
Correct Answer:

Verified
Correct Answer:
Verified
Q45: Readers and writers access sequences of _.<br>A)
Q46: If we want to write objects to
Q47: In _ file access, the file is
Q48: When constructing a Scanner from a File
Q49: Which methods are not in the Serializable
Q51: Caesar cipher uses a shift of each
Q52: In text format, data items are represented
Q53: Which class is used for input of
Q54: How many bytes does the read method
Q55: Which is an advantage of storing numbers