Solved

Assume We Have a RandomAccessFile Object, File, That Stores a Set

Question 48

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents