Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which class is used to create a memory-mapped file for reading and writing?

  1. FileInputStream

  2. RandomAccessFile

  3. MappedByteBuffer

  4. FileChannel

The correct answer is: RandomAccessFile

RandomAccessFile is the correct answer because it is specifically designed for reading and writing files and provides methods for accessing any part of the file. FileInputStream is used for only reading and does not allow for writing to the file. MappedByteBuffer is used for mapping a specific portion of a file to memory and is not used for creating a file. FileChannel does not create a file but is used for reading, writing, and manipulating files. Therefore, RandomAccessFile is the best choice for creating a memory-mapped file for reading and writing.