This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 60 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 60 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What happens if you open a file in w mode and it already exists? A) The file is opened for reading. B) The file is overwritten. C) The file is appended. D) An error occurs. Show Answer Correct Answer: B) The file is overwritten. 2. Which read method(s) will read the entire contents of the file (by default)? A) File.read(). B) File.readlines(). C) File.reads(). D) File.readline(). Show Answer Correct Answer: A) File.read(). 3. How can you delete a file in Python? A) Use the delete() method. B) Use the os.remove() function. C) Use the file. Delete() method. D) None of the above. Show Answer Correct Answer: B) Use the os.remove() function. 4. What does the suffix attribute of a Path object return? A) The extension of the file. B) The name of the file. C) All the above. D) None of the above. Show Answer Correct Answer: A) The extension of the file. 5. What is the difference between 'read()' and 'readlines()'? A) 'read()' reads the file line by line; 'readlines()' reads the entire file at once. B) 'read()' returns a list of strings; 'readlines()' returns a single string. C) 'read()' returns a single string; 'readlines()' returns a list of strings. D) 'read()' returns a byte object; 'readlines()' returns a dictionary of strings. Show Answer Correct Answer: C) 'read()' returns a single string; 'readlines()' returns a list of strings. 6. Name the module that has to be imported to write a csv file. A) Pickle module. B) CSV module. C) Csv module. D) Csv module. Show Answer Correct Answer: B) CSV module. 7. In which mode does a file get created if it doesn't already exist? A) READ mode. B) APPEND mode. C) WRITE mode. D) EXECUTE mode. Show Answer Correct Answer: C) WRITE mode. 8. Why is data stored in a file instead of only using variables in a program? A) To allow data to persist after the program stops running. B) To improve the speed of program execution. C) To reduce memory usage while the program runs. D) To prevent the need for user input. Show Answer Correct Answer: A) To allow data to persist after the program stops running. 9. A(n) ..... access file is also known as a direct access file. A) Sequential. B) Random. C) Numbered. D) Text. Show Answer Correct Answer: B) Random. 10. Which exception is raised when trying to open a file that does not exist? A) FileNotAvailableError. B) FileMissingException. C) FileNotFoundError. D) FileAccessError. Show Answer Correct Answer: C) FileNotFoundError. 11. What is the purpose of the 'newline' parameter in the open() function? A) The 'newline' parameter is used for file permissions. B) The 'newline' parameter controls file encoding. C) The 'newline' parameter determines the file size. D) The 'newline' parameter specifies how newlines are handled in text files. Show Answer Correct Answer: D) The 'newline' parameter specifies how newlines are handled in text files. 12. The w+ mode to facilitate ..... A) Read only. B) Write only. C) Read and Write. D) Append only. Show Answer Correct Answer: C) Read and Write. 13. Ftell() returns ..... A) Current line. B) Size of file. C) Current position of file pointer. D) Error code. Show Answer Correct Answer: C) Current position of file pointer. 14. In which mode do we open a file for reading and writing binary data? A) 'rb'. B) 'wb'. C) 'rb+'. D) 'ab+'. Show Answer Correct Answer: C) 'rb+'. 15. Which of the following function is used with the csv module in Python to read the contents of a csv file into an object A) Csv.write. B) Csv.reader. C) Readrow(). D) Readrows(). Show Answer Correct Answer: B) Csv.reader. 16. Explain the difference between 'read()' and 'readlines()' methods. A) The 'read()' method returns a single string, whereas 'readlines()' returns a list of strings. B) Both 'read()' and 'readlines()' return the same type of data. C) 'read()' reads multiple lines at once, while 'readlines()' reads a single line. D) 'read()' is used for writing files, and 'readlines()' is for reading files. Show Answer Correct Answer: A) The 'read()' method returns a single string, whereas 'readlines()' returns a list of strings. 17. What is the function "w" in file handling A) Read. B) Write. C) Append. D) None of the above. Show Answer Correct Answer: B) Write. 18. How do you allocate memory for an integer variable in C using malloc()? A) Malloc(sizeof(int));. B) Malloc(sizeof(int*));. C) Malloc(int);. D) Malloc(int*);. Show Answer Correct Answer: A) Malloc(sizeof(int));. 19. What is the use of the 'seek' method in file handling? A) The 'seek' method is used to change the file pointer's position in file handling. B) The 'seek' method is used to create a new file. C) The 'seek' method is used to delete a file. D) The 'seek' method is used to read data from a file. Show Answer Correct Answer: A) The 'seek' method is used to change the file pointer's position in file handling. 20. Which of the following is a built-in module in Python? A) Requests. B) Random. C) Numpy. D) Flask. Show Answer Correct Answer: B) Random. 21. What will happen if you try to read from a closed file? A) An error occurs when trying to read from a closed file. B) Reading from a closed file returns an empty string. C) The file will automatically reopen for reading. D) You can still read the last line of the closed file. Show Answer Correct Answer: A) An error occurs when trying to read from a closed file. 22. Which one of the following access mode does not allow writing A) R+. B) R. C) A. D) A+. Show Answer Correct Answer: B) R. 23. Which function is used to move the file position to a desired location within the file? A) Ftell(). B) Rewind(). C) Fseek(). D) Fweek(). Show Answer Correct Answer: C) Fseek(). 24. When reading from text files, which of the following can you use to check ifthe last line of a testfile called (FileA.txt) has been reached? A) WHILE NOT ENDOFFILE. B) WHILE NOT EOF (FILEA.txt). C) WHILE NOT (EOF FILEA.txt). D) WHILE NOT (EOF). Show Answer Correct Answer: B) WHILE NOT EOF (FILEA.txt). 25. What happens if a recursive function does not have a base case? A) It will result in a syntax error. B) It will cause an infinite loop. C) It will terminate prematurely. D) It will return None as the output. Show Answer Correct Answer: B) It will cause an infinite loop. ← 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