This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 35 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 35 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What happens if you try to write to a file that does not exist? A) The file is ignored and no action is taken. B) The file is created and then written to. C) The file is opened in read-only mode. D) The file cannot be created and an error is thrown. Show Answer Correct Answer: B) The file is created and then written to. 2. What does ftell() function return in C? A) Current position of the file pointer. B) Total bytes in the file. C) Number of lines in the file. D) Size of the file. Show Answer Correct Answer: A) Current position of the file pointer. 3. What is the data type of data read to and from a file? A) String. B) Integer. C) Real. D) Boolean. Show Answer Correct Answer: A) String. 4. Which of the following is used to read all lines in a file as a list? A) Read(). B) Readline(). C) Readlines(). D) All(). Show Answer Correct Answer: C) Readlines(). 5. If we want to add new data without overwriting the previous content then we should write using ..... mode A) "w". B) "r". C) "a". D) None. Show Answer Correct Answer: C) "a". 6. What is the purpose of the 'close()' function in programming languages when working with files? A) To delete the file from the system. B) To save changes to the file. C) To close the file and ensure all operations are complete. D) To open a new file. Show Answer Correct Answer: C) To close the file and ensure all operations are complete. 7. Which of the following is not a standard exception in Python? A) NameError. B) IOError. C) AssignmentError. D) ValueError. Show Answer Correct Answer: C) AssignmentError. 8. Which Python function is used to open a text file for reading? A) Open("file.txt", "w"). B) Open("file.txt", "r"). C) Read("file.txt"). D) Write("file.txt"). Show Answer Correct Answer: B) Open("file.txt", "r"). 9. A binary file stores information in ASCII or Unicode characters. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 10. In which scenario would you use the 'APPEND' mode? A) To overwrite existing data. B) To add new data at the end of a file. C) To create a new file. D) To read data from a file. Show Answer Correct Answer: B) To add new data at the end of a file. 11. Which mode in Python is used to open a file for reading? A) W. B) A. C) R. D) X. Show Answer Correct Answer: C) R. 12. How can you read a file using a context manager? A) Use 'open(filename)' to read a file. B) Read a file by calling 'file.read()' directly. C) Use 'with open(filename, mode) as file:' to read a file. D) Use 'open(filename, mode)' without 'with' to read a file. Show Answer Correct Answer: C) Use 'with open(filename, mode) as file:' to read a file. 13. The ..... character is used to seprate the values in TSV files. A) . B) ,. C) :. D) $\rightarrow$. Show Answer Correct Answer: D) $\rightarrow$. 14. Kamut accidentally used "w" mode on a project file that contains important information. What is the immediate risk? A) The file becomes read-only. B) The file might get locked. C) The existing file content will be permanently erased. D) The file will not open at all. Show Answer Correct Answer: C) The existing file content will be permanently erased. 15. Files need to be closed when using file handling in order to save data A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 16. What does the 'read ..... text()' method do? A) Creates a new text file. B) Reads the contents of a text file as a string. C) Deletes the contents of a text file. D) Writes text to a file. Show Answer Correct Answer: B) Reads the contents of a text file as a string. 17. The read() is indicate ..... A) Read a particular byte. B) Read a line. C) Read a lines. D) All these. Show Answer Correct Answer: A) Read a particular byte. 18. What is the use of tell() method in Python? A) The tell() method returns the current position of the file cursor in a file object. B) The tell() method closes the file object. C) The tell() method writes data to a file. D) The tell() method opens a file for reading. Show Answer Correct Answer: A) The tell() method returns the current position of the file cursor in a file object. 19. What function is used to write data to a binary file? A) Store. B) Write. C) Save. D) Append. Show Answer Correct Answer: B) Write. 20. Which function is used to close the file? A) Close(). B) End(). C) Terminate. D) None. Show Answer Correct Answer: A) Close(). 21. Which command is used to close an open file in a program? A) WRITEFILE. B) OPENFILE. C) CLOSEFILE. D) READFILE. Show Answer Correct Answer: C) CLOSEFILE. 22. What is the difference between absolute and relative paths? A) Absolute paths begin with the root folder, relative paths do not. B) Both are the same. C) Relative paths are longer. D) Absolute paths are only for Windows. Show Answer Correct Answer: A) Absolute paths begin with the root folder, relative paths do not. 23. Which step is necessary after writing to a file? A) Open the file. B) Close the file. C) Delete the file. D) Rename the file. Show Answer Correct Answer: B) Close the file. 24. What is a CSV file and how is it different from a text file? A) A CSV file is a database format that requires special software to read. B) A CSV file is a structured text file that organizes data in rows and columns using commas as delimiters, while a text file is an unstructured file that can contain any text. C) A CSV file is a type of image file used for graphics. D) A CSV file is a binary file that cannot be opened in a text editor. Show Answer Correct Answer: B) A CSV file is a structured text file that organizes data in rows and columns using commas as delimiters, while a text file is an unstructured file that can contain any text. 25. Which exception is thrown by read() method? A) SystemInputException. B) IOException. C) SystemException. D) InterruptedException. Show Answer Correct Answer: B) IOException. ← PreviousNext →Related QuizzesClass 11 Computer Science Chapter 6 File Handling Quiz 1Class 11 Computer Science Chapter 6 File Handling Quiz 2Class 11 Computer Science Chapter 6 File Handling Quiz 3Class 11 Computer Science Chapter 6 File Handling Quiz 4Class 11 Computer Science Chapter 6 File Handling Quiz 5Class 11 Computer Science Chapter 6 File Handling Quiz 6Class 11 Computer Science Chapter 6 File Handling Quiz 7Class 11 Computer Science Chapter 6 File Handling Quiz 8Class 11 Computer Science Chapter 6 File Handling Quiz 9Class 11 Computer Science Chapter 6 File Handling Quiz 10 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books