πŸŽ“ BookMCQ
← Back to 11. File System Interface

πŸ“ File Storage structure in Operating System (16 MCQs)

Physical and Logical Organisation of Stored Files

File storage structure describes how the file system places file contents and metadata into storage-device blocks. The operating system manages allocation structures that map logical file positions to physical or logical storage locations. Common methods include contiguous allocation, linked allocation, and indexed allocation. These methods influence access speed, fragmentation, storage overhead, file growth, and the reliability of file retrieval.

Why File Blocks Require an Allocation Strategy

Files can grow, shrink, and be accessed sequentially or randomly, while physical storage has finite capacity. The file system therefore needs a method to assign blocks and track their ownership. Contiguous allocation supports efficient access but can fragment free space. Linked allocation simplifies growth but complicates random access, while indexed allocation requires additional index structures.

Contiguous, Linked and Indexed Block Allocation

Contiguous allocation stores a file in consecutive blocks and records its starting location and length. Linked allocation connects each block to the next through pointers. Indexed allocation maintains a separate index block containing references to the file's data blocks. The file system selects and maintains these structures during file creation, expansion, deletion, and access.

Allocating a File Across Storage Blocks

Suppose a file requires five blocks and the disk begins allocating it at block 20. Contiguous allocation uses blocks 20 through 24. Linked allocation may use blocks 20, 35, 12, 41, and 28, connected through pointers. Indexed allocation stores these five block addresses in an index structure for retrieval.

Access Performance, Fragmentation and Metadata Costs

Contiguous allocation provides fast sequential and direct access but may require compaction or relocation when large free regions are unavailable. Linked allocation supports flexible growth but introduces pointer overhead and poor random-access performance. Indexed allocation enables direct block lookup but consumes index storage. Modern file systems may combine allocation techniques with extents, caching, and metadata optimisation.

Common Confusions About File Allocation

'Linked allocation always stores blocks next to each other' is incorrect because pointers can connect scattered blocks. 'Indexed allocation stores every file in one index block regardless of size' is incorrect because larger files may require multilevel structures. 'Contiguous allocation eliminates all storage overhead' is incorrect because file metadata and allocation bookkeeping are still required.

Exam Focus: Allocation Diagrams and Access Costs

Draw block-allocation diagrams for contiguous, linked, and indexed methods. Calculate the blocks required by a file and identify the metadata needed to retrieve them. Compare sequential and direct access performance, fragmentation, and file-growth flexibility. Questions may also examine how linked allocation differs from indexed allocation in pointer organisation and random retrieval.

Key Terms of File Storage Structure

  • Contiguous allocation - Stores consecutive file blocks.
  • Linked allocation - Connects blocks through pointers.
  • Indexed allocation - Uses a separate block index.
  • Extent - Consecutive allocated block range.
  • Fragmentation - Inefficiently divided storage space.
  • Index block - Stores data-block addresses.
3
Easy
8
Medium
5
Hard

πŸ“ All File Storage structure in Operating System MCQs

Q1. Which file extension is commonly associated with Microsoft Word documents?

A..docx βœ…
B..pdf
C..txt
D..exe
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– Explanation: The correct answer is .docx because it is the standard extension for Word documents created by recent versions of Microsoft Office. The .pdf extension represents portable document format, which is view‑only and not editable by Word. .txt denotes plain text files without formatting, and .exe is an executable binary, not a document. Understanding extensions helps users choose the right program to open or edit a file, preventing errors and saving time.

Q2. What extension is used for compiled Java bytecode files?

A..java
B..class βœ…
C..jar
D..exe
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Compiled Java code is stored in .class files, which contain bytecode the JVM executes. The .java extension is for source files that must be compiled first. A .jar file is an archive that can bundle many .class files together, but it is not the individual compiled output. .exe is a Windows executable unrelated to Java. Recognizing the correct extension ensures the JVM can locate and run the program correctly.

Q3. Why do operating systems rely on file extensions to determine how to open a file?

A.They store metadata about the file
B.They provide a hint to applications βœ…
C.They encrypt the file contents
D.They set file permissions
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Operating systems treat the extension as a hint that tells applications which program is appropriate for opening the file. Metadata storage, encryption, and permission settings are handled by other mechanisms, not by the extension itself. By using extensions, the OS can quickly associate a file with the right software, improving usability and reducing user confusion.

Q4. How does the .exe extension differ from .com in terms of typical file size and structure?

A..exe files are usually larger and contain a header βœ…
B..com files are larger and contain a header
C.Both are identical in size and structure
D..com files contain metadata unlike .exe
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: An .exe file generally includes a header, relocation information, and can be larger because it supports more complex programs. A .com file is a simple, flat binary limited to 64β€―KB and lacks a header, making it smaller. The other options misstate the relationship; they either reverse the size comparison or claim they are identical, which is inaccurate. Knowing this helps developers choose the proper format for their needs.

Q5. In a multi‑platform environment, what limitation arises from relying solely on file extensions to identify file types?

A.Extensions may be ambiguous across operating systems βœ…
B.Extensions increase file size
C.Extensions prevent compression
D.Extensions cause security vulnerabilities
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Extensions can be ambiguous because the same extension may represent different formats on different systems (e.g., .txt can be plain text on Windows but a script on Unix). The other statements are false: extensions do not affect file size, they do not inhibit compression, and while they can be misused, the primary limitation is ambiguity. This insight guides designers to use additional file‑type detection methods.

Q6. How do archive file extensions like .zip or .tar convey information about their contents compared to a simple .txt file?

A.They indicate a compressed collection of files βœ…
B.They indicate plain text data
C.They indicate an executable program
D.They indicate image data
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: The .zip and .tar extensions signal that the file contains multiple items packaged together, often compressed, which differs from a .txt file that holds only readable characters. The other options incorrectly label the purpose of these extensions. Recognizing this distinction helps users choose appropriate tools for extraction or viewing, preventing data loss or misinterpretation.

Q7. If a user creates a shell script named 'backup' without an extension, which action will allow the script to be run as a command in a Unix‑like system?

A.Rename the file to backup.sh
B.Change the file permission to executable
C.Both rename and permission change βœ…
D.Do nothing; it will run automatically
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: To execute a script, the system must recognize it as executable (chmod +x) and typically expects the .sh extension for clarity. Renaming alone does not grant execution rights, and permission change alone may work but lacks the conventional hint. Therefore, performing both steps ensures the script is both identifiable and runnable, reflecting best practices for script management.

Q8. A developer has source files named 'module.c', 'module.h', and 'module.o'. Which file should be linked to produce an executable, and what extension indicates its readiness?

A.module.c (source)
B.module.h (header)
C.module.o (object) βœ…
D.None of them
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: The .o file is the compiled object file ready for linking; its extension signals that compilation is complete. The .c file is raw source code and must be compiled first, while the .h file provides declarations and is not linked directly. Selecting 'None' would ignore the necessary step. Understanding these stages helps developers manage build processes efficiently.

Q9. During deployment, a team receives a file named 'report' with no extension. The application expects .pdf files. What is the most reliable way to verify the file type before opening?

A.Rely on the file name
B.Open with a text editor
C.Use a file‑command utility to inspect magic numbers βœ…
D.Assume it is a PDF
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: Inspecting the file's magic number with a utility like 'file' examines its internal header, providing a trustworthy identification regardless of the missing extension. Simply trusting the name or assuming a type can lead to errors, and opening with a text editor may garble binary data. Accurate verification prevents crashes and maintains workflow integrity.

Q10. An archive contains files with mixed extensions: .docx, .exe, .sh, .jpg. The security policy forbids executing any .exe or .sh files. Which automated method can enforce this policy before extraction?

A.Filter by extension during unzip
B.Scan file contents for signatures
C.Both filter by extension and scan signatures βœ…
D.Rely on user discretion
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: Combining extension filtering with signature scanning ensures that prohibited executables are blocked both by name and by actual content, covering cases where extensions are spoofed. Solely filtering may miss renamed malicious files, while only scanning signatures could be slower. User discretion alone is unreliable. This layered approach aligns with robust security practices.

Q11. A cross‑platform project uses .dll on Windows and .so on Linux for shared libraries. When compiling on macOS, which extension should be used, and why is the extension important for the linker?

A..dylib because the linker searches by extension βœ…
B..dll because it is universal
C..so because it is Linux compatible
D.No extension is needed
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: macOS uses .dylib for dynamic libraries, and the linker relies on the extension to locate appropriate files during the build. Using .dll or .so would cause the linker to miss the library, leading to build failures. Omitting an extension removes the hint entirely. Selecting the correct extension ensures successful linking and runtime loading across platforms.

Q12. A user tries to open a 'data' file that is actually a CSV but lacks a .csv extension. Which of the following steps ensures the spreadsheet program reads it correctly?

A.Rename to data.csv
B.Import the file specifying the delimiter
C.Both rename and import steps βœ…
D.Cannot open without .csv
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: Renaming gives the program an obvious hint, while importing with delimiter settings guarantees correct parsing even if the name is unchanged. Doing either alone may still work but is less reliable; assuming the program cannot open the file is false because many applications can import raw data. Combining both actions maximizes compatibility and reduces user error.

Q13. A developer accidentally commits a binary executable with a .exe extension that should have been ignored. What git attribute should be set to prevent future accidental commits of such files?

A..gitattributes with binary
B..gitignore with *.exe βœ…
C..gitconfig with core.autocrlf
D..gitmodules with submodule
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Adding *.exe to .gitignore tells Git to ignore any file with that extension, preventing it from being staged or committed. .gitattributes marks files as binary but does not stop them from being added. .gitconfig deals with line‑ending conversions, and .gitmodules manages submodule references. Properly configuring .gitignore maintains a clean repository and avoids unnecessary binary blobs.

Q14. Why might an operating system allow a file to have no extension, yet still correctly open it with the appropriate application?

A.The OS uses file signatures βœ…
B.The OS guesses based on file size
C.The OS cannot open without an extension
D.The OS uses user preferences
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: Modern operating systems can examine a file's internal magic number or header to determine its format, allowing them to launch the correct application even when no extension is present. Guessing based on size is unreliable, and the system is capable of opening files without extensions when signatures are recognized. Understanding this mechanism helps users manage files more flexibly.

Q15. Explain how the use of file extensions as 'hints' can lead to security risks when users download files from the internet.

A.Extensions can be misleading βœ…
B.Extensions encrypt files
C.Extensions increase file size
D.Extensions improve performance
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Malicious actors can name a harmful file with a benign extension (e.g., .txt) to trick users into opening it, or they can rely on the OS to execute files based solely on extension, bypassing deeper inspection. Encryption, file size, and performance are unrelated to security concerns. Recognizing this risk encourages users to verify file content through additional methods, such as scanning for malware.

Q16. A multimedia editing suite accepts .mp4 and .mov files. A user has a video file named 'clip' with no extension. Which workflow ensures the suite recognizes the file type without renaming?

A.Open the file directly
B.Use 'Open With' and select format
C.Check the file header and import accordingly βœ…
D.Cannot open without an extension
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: Inspecting the file's header reveals its container format, allowing the suite to import it correctly even without an extension. Opening directly may fail if the program relies on extensions, and manually selecting a format without verification could cause errors. Assuming the file cannot be opened is false because many applications can detect format via headers. This approach safeguards workflow continuity.

πŸ”— Related Topics (MCQs)