📝 How many File types in file system (15 MCQs)
Classification of Files by Purpose and Representation
File types identify the nature and intended use of stored information within an operating system. Common categories include ordinary data files, executable files, source-code files, directories, and device-related special files. Operating systems recognise file types through metadata, naming conventions, internal formats, or application-specific information. Classification helps determine how files are interpreted, accessed, executed, or managed by system utilities.
Why File Classification Supports Operating System Services
Different files require different handling. Executable files must satisfy program-loading requirements, directories contain file-system organisation information, and device files provide interfaces to hardware or virtual devices in systems that support them. File extensions help users identify content, but extensions alone cannot reliably establish a file's actual format or execution permissions.
Recognising Types Through Metadata and System Conventions
The file system records attributes and may identify special categories through metadata. Applications inspect extensions, file signatures, or content formats to determine how information should be processed. Unix-like systems distinguish regular files, directories, symbolic links, and special files through file metadata. Windows commonly associates filename extensions with registered applications and executable format conventions.
Identifying Several Common File Categories
Consider a directory containing report.txt, program.exe, image.png, and a subdirectory named documents. The text file stores readable characters, the executable contains a loadable program image, the PNG file contains encoded image data, and the directory records references to filesystem objects. Their names and underlying metadata help determine how applications and the operating system handle them.
Compatibility, Security and Format Recognition
File classification improves organisation, application association, and system handling. However, incorrect extensions can mislead users and utilities, while malicious files may disguise executable content using harmless-looking names. Operating systems must rely on appropriate execution permissions and format validation rather than trusting filename extensions alone. Some file types also require specialised applications or libraries to interpret their contents.
Clarifying Extensions and Actual File Types
'Changing an extension converts the internal file format' is incorrect because renaming does not transform file contents. 'Every executable file must use the .exe extension' is incorrect because executable formats and naming conventions differ across systems. 'A directory is simply an ordinary text document' is incorrect because it is a special filesystem structure containing references to other objects.
Exam Focus: Regular, Directory and Special Files
Distinguish regular files, executable files, directories, symbolic links, character devices, and block devices. Understand how extensions differ from filesystem metadata and file signatures. Identify the handling required for different categories. Questions may also compare Unix-like file classifications with Windows filename-extension associations and test why renaming alone does not change file contents.
Key Terms of File Classification
- Regular file - Stores ordinary data.
- Executable - Contains loadable program code.
- Directory - Organises filesystem entries.
- Symbolic link - References another pathname.
- File extension - Indicates a naming-based format.
- File signature - Identifies content format.
📝 All How many File types in file system MCQs
Q1. What is the primary characteristic of a text file?
📖 Explanation: A text file is defined by its human‑readable characters arranged in lines, which makes it easy to edit with a simple editor. Option B describes a generic binary file, not a text file. Option C refers to source code structure, and Option D describes an executable file format. In real‑world use, a programmer saving a log file expects each line to be readable, confirming that the line‑based character sequence is the defining trait.
Q2. Why does an operating system abstract physical storage into files?
📖 Explanation: The OS presents files as logical units so programs can read and write data without needing to know the exact disk geometry or media type. This abstraction simplifies development and improves portability. Option B is unrelated to storage abstraction, Option C describes a security feature not inherent to file abstraction, and Option D concerns hardware power management, not logical representation. In practice, a text editor can save a document on any drive because the OS handles the mapping.
Q3. A developer wants to keep source code separate from compiled binaries. Which file types should be used?
📖 Explanation: Source files contain human‑readable programming language statements, while executable files hold machine‑code sections ready for the loader. Using only text files (Option A) would not allow the system to run the code directly. Binary files (Option C) are not human‑readable, making source editing difficult. Option D reverses the roles, which is impractical. In a typical build process, developers store .c or .java files as source and .exe or .class files as executables.
Q4. A sensor logs measurements line by line and must be processed by a script that reads each line sequentially. Which file type is most appropriate?
📖 Explanation: A line‑by‑line script works naturally with a text file because each measurement appears as a readable line separated by newline characters. A binary file (Option B) would require parsing of raw bytes, complicating the script. An executable file (Option C) contains code, not raw data, and a source file (Option D) is meant for compilation, not direct data storage. In real‑world IoT deployments, logs are often saved as plain text to simplify analysis with tools like grep or awk.
Q5. How does the structure of a source file differ from that of an executable file?
📖 Explanation: Source files are written by programmers and consist of declarations, function definitions, and statements in a high‑level language. Executable files, by contrast, consist of compiled machine‑code sections that the loader can place in memory and run. Option A ignores the defined structures, Option C swaps the roles, and Option D falsely claims they are identical. Understanding this distinction helps a developer know why source files must be compiled before execution.
Q6. Which attribute is used by humans to identify a file?
📖 Explanation: A file name provides a human‑readable label that users can type or see in directory listings. Size (Option B) is a numeric attribute, Owner (Option C) indicates who created the file, and Permission (Option D) controls access rights; none of these serve as the primary identifier for a person. In everyday use, a user searches for report.txt by name, confirming that the name is the key attribute for identification.
Q7. When backing up files, which attribute must be preserved to ensure they can be correctly opened later?
📖 Explanation: The structure defines how the data is organized inside the file (e.g., lines for a text file or sections for an executable). Preserving structure guarantees that applications can interpret the file correctly after restoration. The name (Option A) helps locate the file but does not affect its internal format. Content (Option B) is the actual data, which is also important, but without the proper structure the data may be unreadable. Permissions (Option D) affect access, not file format. In backup software, storing the file’s structure is essential for recovery.
Q8. In what way does treating a file as a logical storage unit affect data persistence?
📖 Explanation: Logical storage abstracts the physical medium, allowing the OS to write data to non‑volatile devices so the information survives power cycles. Compression (Option B) and encryption (Option C) are optional features, not inherent to the logical concept. Network speed (Option D) relates to transmission, not persistence. For example, a word processor saves a document; because the file is a logical unit stored on a hard drive, the document is still available after the computer restarts.
Q9. A digital camera stores photos and videos. Which file type classification best describes the image files?
📖 Explanation: Photos are stored as binary data because they consist of bytes representing pixel values and compression headers, not readable characters. Text files (Option B) would be inefficient for image data. Source files (Option C) are meant for program code, and executable files (Option D) contain machine instructions. In real life, JPEG or PNG files are binary, enabling efficient storage and quick decoding by image viewers.
Q10. A user writes a report using a word processor. Which type of file is most likely created?
📖 Explanation: Word processors typically save documents as text‑based formats (e.g., .txt, .rtf) that consist of characters organized into lines, making them editable and searchable. Source files (Option B) contain programming code, executables (Option C) contain machine code, and binary files (Option D) store data in non‑readable byte sequences. When the user opens the saved document later, the program reads the line‑based text structure to display the content.
Q11. How does the operating system map a file onto physical devices?
📖 Explanation: The OS maintains a file allocation table (or similar metadata structure) that records which disk blocks belong to each file, allowing the system to locate and retrieve the file’s data on physical media. Network protocols (Option B) handle data transmission, not local storage mapping. CPU registers (Option C) hold temporary data, and user input (Option D) does not dictate block allocation. This mapping lets a user open a file without knowing where on the disk the data resides.
Q12. A system must load code sections directly into memory for execution. Which file type should be used?
📖 Explanation: Executable files contain prepared code sections that the loader can place into memory and run immediately. Source files (Option B) require compilation before execution, text files (Option C) hold readable characters, and generic binary files (Option D) may not have the necessary metadata for loading. In practice, an operating system loads a .exe or .elf file because it already includes the required executable sections.
Q13. What is the term for a collection of related information stored on secondary storage?
📖 Explanation: A file is defined as a named collection of related data kept on secondary storage devices such as disks or tapes. A process (Option B) is an executing program, a thread (Option C) is a lightweight unit of execution, and a buffer (Option D) is a temporary memory area. When a user saves a document, they are creating a file that can be retrieved later.
Q14. Why might a programmer choose to store configuration data in a text file rather than a binary file?
📖 Explanation: Text files are human‑readable, allowing developers and system administrators to edit configuration parameters directly without special tools. Speed (Option B) can be similar for small files, security (Option C) depends on encryption rather than format, and binary files (Option D) are often larger due to lack of compression. In real deployments, editing a .conf file is straightforward, which is why readability is the primary advantage.
Q15. A mixed file contains both program code and embedded data. How should the operating system treat it?
📖 Explanation: When a file contains executable code sections along with embedded data, the OS classifies it as an executable so the loader can map code into memory and provide access to the data. Treating it as a source file (Option A) would require compilation, which is not needed for execution. A text file (Option C) lacks the binary code structure, and a generic binary file (Option D) does not convey that the file is intended for execution. Thus, the OS loads it as an executable.