This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 14 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 14 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which of the following commands can be used to read the remaining lines in a file using the file object ? A) Tmpfile.read(n). B) Tmpfile.read(). C) Tmpfile.readline(). D) Tmpfile.readlines(). Show Answer Correct Answer: D) Tmpfile.readlines(). 2. Which function will remove a file from the directory? A) Os.path.delete(). B) Os.path.remove(). C) Os.delete(). D) Os.remove(). Show Answer Correct Answer: B) Os.path.remove(). 3. What does the 'readline()' function do? A) Reads one line from the file. B) Writes a new line in the file. C) Deletes a line from the file. D) Reads the entire file at once. Show Answer Correct Answer: A) Reads one line from the file. 4. What does the 'readline()' method do? A) Reads the entire file as a string. B) Reads a single line from the file. C) Writes a single line to the file. D) Returns a list of all lines in the file. Show Answer Correct Answer: B) Reads a single line from the file. 5. What is the purpose of rename()? A) Renames a file. B) Deletes a file. C) Checks for end of file. D) Opens a file. Show Answer Correct Answer: A) Renames a file. 6. What is the purpose of the 'with' statement in file handling? A) The 'with' statement in file handling is used to ensure that files are properly opened and closed. B) To append data to a file without opening it first. C) To create a new file without closing it afterwards. D) To read the contents of a file into memory. Show Answer Correct Answer: A) The 'with' statement in file handling is used to ensure that files are properly opened and closed. 7. What happens if you try to read from a file that has been opened in write mode? A) Reading from a file opened in write mode will result in an error. B) The content will be written to the file instead of being read. C) The file will be opened in read mode automatically. D) The file will be read successfully without any issues. Show Answer Correct Answer: A) Reading from a file opened in write mode will result in an error. 8. What will be the output of the following statement in python? (fh is a file handle) fh.seek(-30, 2) Options:-It will place the file pointer:- A) At 30th byte ahead of current current file pointer position. B) At 30 bytes behind from end-of file. C) At 30th byte from the beginning of the file. D) At 5 bytes behind from end-of file . Show Answer Correct Answer: B) At 30 bytes behind from end-of file. 9. Which function writes a character to a file? A) Putfile(). B) Fputc(). C) Fileput(). D) Write(). Show Answer Correct Answer: B) Fputc(). 10. What mode would you use to write to a file, overwriting its contents? A) R. B) A+. C) W. D) A. Show Answer Correct Answer: C) W. 11. Appending to a file means adding extra data into the file. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 12. Which step creates a connection between a file and a program? A) Open the file. B) Read the file. C) Process the file. D) Close the file. Show Answer Correct Answer: A) Open the file. 13. Explain the process of reading from a file in Python. A) Open the file $\rightarrow$ Read the contents using 'read' method $\rightarrow$ Close the file. B) Open the file $\rightarrow$ Write the contents using 'write' method $\rightarrow$ Close the file. C) Read the file $\rightarrow$ Execute the contents $\rightarrow$ Close the file. D) Open the file $\rightarrow$ Read the contents using 'print' method $\rightarrow$ Close the file. Show Answer Correct Answer: A) Open the file $\rightarrow$ Read the contents using 'read' method $\rightarrow$ Close the file. 14. What is the output of following program#include int main()\{ extern int i; printf("%d ", i); \{ int i = 10; printf("%d ", i); \} return 0; \} A) 0 10. B) 0 0. C) 10 10. D) Compiler error. Show Answer Correct Answer: D) Compiler error. 15. Which of the following needs to be used to provide access to the file throughout a program? A) File descriptor. B) File writer. C) File changer. D) File type. Show Answer Correct Answer: A) File descriptor. 16. ..... method writes all given rows to the csv file. A) Writerow(). B) Writerows(). C) Writeln(). D) Writelines(). E) Writeline(). Show Answer Correct Answer: B) Writerows(). 17. Full form of CSV. A) Case Sensitive Value. B) Core Subject Value. C) Case Separated Values. D) Comma Separated Values. Show Answer Correct Answer: D) Comma Separated Values. 18. Simple programs can't make use of text files to store data for access again A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 19. The default file mode is ..... mode: A) R. B) W. C) R+. D) W+. Show Answer Correct Answer: A) R. 20. Which statement is TRUE about file reading in Python? A) Read() reads line by line. B) Readline() reads the whole file. C) Readlines() reads entire file into a list. D) Read() returns list of strings. Show Answer Correct Answer: C) Readlines() reads entire file into a list. 21. What is the purpose of the 'with' statement when handling files? A) The 'with' statement is a method for encrypting file contents. B) The 'with' statement is used to read files line by line. C) The 'with' statement ensures proper management of file resources by automatically closing the file after its block of code is executed. D) The 'with' statement allows multiple files to be opened simultaneously. Show Answer Correct Answer: C) The 'with' statement ensures proper management of file resources by automatically closing the file after its block of code is executed. 22. What keyword in Python is used to load other Python source code files into your current code page? A) Load. B) Require. C) Import. D) Include. Show Answer Correct Answer: C) Import. 23. The data files are the files that stored ..... to specific application for later use. A) Files. B) Data. C) Hard Disk. D) Database. Show Answer Correct Answer: B) Data. 24. File data.txt contains "Hello" .f=open("data.txt", "w")f.write("World")f.close()What will be the content of file? A) HelloWorld. B) WorldHello. C) World. D) Error. Show Answer Correct Answer: C) World. 25. What will the following code do?with open('test.txt', 'w') as file:file.write("Hello World") A) Raise an error because the file doesn't exist. B) Write "Hello World" to 'test.txt'. C) Append "Hello World" to 'test.txt'. D) Read the contents of 'test.txt'. Show Answer Correct Answer: B) Write "Hello World" to 'test.txt'. ← 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