Q: 1 Each file can be accessed through a file mode. These file modes decide what action can be performed in the file. If the file mode is <r> then we can only _________ the contents of the file.
Read
Write
Delete
Overwrite
[ Option A ]
File modes control the type of access you have to a file. When a file is opened in the mode <r>, it means the file is opened for reading only. In this mode, you can only view or read the contents of the file, but you cannot make any changes like writing, deleting, or overwriting the file.
| FILE MODE | OPERATIONS ALLOWED | DESCRIPTION |
|---|---|---|
| r | Read | Open for reading only. File must exist, otherwise, error occurred. |
| w | Write | Open for writing only. Overwrites existing file or creates new file if it does not exist. |
| a | Append (Write) | Open for appending. Data written will be added to the end. Creates file if it does not exist. |
| r+ | Read and Write | Open for both reading and writing. File must exist, otherwise, error occurred. |
| w+ | Read and Write | Open for reading and writing. Overwrites or creates new. |
| a+ | Read and Write | Open for reading and appending. Creates file if it does not exist. |
| rb | Read Binary Data | Open for reading in binary mode. File must exist. |
| wb | Write Binary Data | Open for writing in binary mode. Overwrites or creates new. |
| ab | Append (Write binary data) | Open for appending in binary mode. Creates file if doesn't exist. |
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.