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
Q43: The values of the byte type range
Q44: Why does FileInputStream override the read method
Q45: Assume we have a RandomAccessFile object, file,
Q46: Assume we have a RandomAccessFile object, file,
Q47: In which of the following modes can
Q49: _ access allows file access at arbitrary
Q50: Assume we have a RandomAccessFile object, file,
Q51: In Java, the byte type is a(n)
Q52: Given a RandomAccessFile that stores a set
Q53: You would need a Caesar cipher with
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents