Assume we have a RandomAccessFile object, file, which 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 25th record, which code correctly modifies the 25th record by changing its color to Color.yellow through the setColor method?
A) myData.read(file) ;
MyData.setColor(Color.yellow) ;
MyData.write(file) ;
B) myData.read(file) ;
MyData.setColor(Color.yellow) ;
File.seek(file.getFilePointer() ) ;
MyData.write(file) ;
C) myData.read(file) ;
MyData.setColor(Color.yellow) ;
File.seek(file.getFilePointer() + MyData.RECORD_SIZE) ;
MyData.write(file) ;
D) long loc = file.getFilePointer() ;
MyData.read(file) ;
MyData.setColor(Color.yellow) ;
File.seek(loc) ;
MyData.write(file) ;
Correct Answer:
Verified
Q45: Assume we have a RandomAccessFile object, file,
Q46: Assume we have a RandomAccessFile object, file,
Q47: In which of the following modes can
Q48: Assume we have a RandomAccessFile object, file,
Q49: _ access allows file access at arbitrary
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
Q54: Which of the following classes are used
Q55: Which code stores an array buttonArray of
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