← Back to 11. File System Interface

📝 Direct file access Method

📖 From Operating System • 11. File System Interface • 13 questions available

Practice MCQs for Direct file access Method. Test your knowledge with carefully crafted questions across easy, medium, and hard difficulty levels.

🔄 Last updated: 2026-07-26

3
Easy Questions
6
Medium Questions
4
Hard Questions

📝 Sample Questions

Q1. A Java program must obtain an exclusive lock on the first half of a file named file.txt whose size is 2000 bytes. Which call to FileChannel.lock correctly acquires this lock?

🔹 A. ch.lock(0, 1000, false)
🔹 B. ch.lock(0, 2000, false)
🔹 C. ch.lock(0, 1000, true)
🔹 D. ch.lock(1000, 1000, false)

💡 Difficulty: easy | ✅ Correct: A

Q2. Two threads need to coordinate file access: Thread 1 must obtain an exclusive lock on the first half of a file, while Thread 2 needs a shared lock on the second half. Which ordering of lock acquisition avoids a deadlock?

🔹 A. Thread 1 locks first half exclusively, then Thread 2 locks second half shared
🔹 B. Thread 2 locks second half shared, then Thread 1 locks first half exclusively
🔹 C. Both threads try to lock their portions at the same time
🔹 D. Thread 1 locks first half exclusively, releases it, then Thread 2 locks second half shared

💡 Difficulty: medium | ✅ Correct: D

Q3. An operating system uses advisory locking. Process A acquires an exclusive lock on a log file. Process B later writes to the same file without explicitly acquiring any lock. What is the most likely outcome?

🔹 A. Process B’s write succeeds because advisory locks are ignored unless Process B also checks for locks
🔹 B. Process B is blocked until Process A releases its lock
🔹 C. Process B throws an IOException immediately
🔹 D. Process B’s write corrupts the file but the OS allows it

💡 Difficulty: hard | ✅ Correct: A

⬆️ View all questions in the quiz below

🔗 Related Topics

📝 File attributes concepts📝 File operations concepts📝 How many File types in file system📝 File structure in file system📝 Internal file structure
🚀 Start Quiz 📝 Practice Mode