This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 50 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 50 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What is the output of 'os.path.abspath('.')'? A) The root directory. B) The parent directory. C) The home directory. D) The current working directory. Show Answer Correct Answer: D) The current working directory. 2. Opening a file with write access causes the contents of the file to removed first. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 3. Which function is used to read all characters and return it in form a string? A) Read(). B) Readall(). C) Readchars(). D) Readlines(). Show Answer Correct Answer: A) Read(). 4. The text files stores information in the form of ..... A) ASCII. B) UNICODE. C) Both A and B. D) None of this. Show Answer Correct Answer: C) Both A and B. 5. What is a file in the context of computer programming? A) A function to read and write data. B) A type of data structure. C) A type of variable used to store data. D) A collection of bytes stored in a device. Show Answer Correct Answer: D) A collection of bytes stored in a device. 6. What does the 'os.path.getsize()' function return? A) The size of the file path. B) The size of a directory. C) The size of a file in bytes. D) The total size of all files in a directory. Show Answer Correct Answer: C) The size of a file in bytes. 7. The two writing functions for python text files are ..... and ..... A) Write() and writeline(). B) Write()and writelines(). C) Writerow() and writerows(). D) Dump() and load(). Show Answer Correct Answer: B) Write()and writelines(). 8. When reading a line from a text file called file.txt into a variable called linetext, which of the following should we use? A) READFILE file.txt, linetext. B) READFILE (file.txt) linetext. C) READFILE (file.txt, linetext). D) READFILE (linetext, file.txt). Show Answer Correct Answer: A) READFILE file.txt, linetext. 9. What does the 'READ' mode do when a file is opened in this mode? A) Adds data to the file. B) Reads data from the file. C) Overwrites data in the file. D) Deletes the file. Show Answer Correct Answer: B) Reads data from the file. 10. Fwrite() returns: A) Number of characters written. B) Nothing. C) Number of items written. D) -1 when error. Show Answer Correct Answer: C) Number of items written. 11. What is virtual memory and how does it work? A) Virtual memory is a memory management technique that uses disk space to extend RAM, allowing for larger applications to run. B) Virtual memory is a type of physical storage that increases CPU speed. C) Virtual memory is a technique that compresses RAM to save space. D) Virtual memory is a method that uses network resources to enhance processing power. Show Answer Correct Answer: A) Virtual memory is a memory management technique that uses disk space to extend RAM, allowing for larger applications to run. 12. The method to set the file marker position. A) Seek(. B) Search(). C) Seek(). D) Search(. Show Answer Correct Answer: C) Seek(). 13. The ..... statement is used to execute as a pair operations. A) Seek(). B) Pickle. C) Unpicked. D) With. Show Answer Correct Answer: D) With. 14. Which function is used to delete a file? A) Remove(). B) Deletefile(). C) Unlink(). D) Fdelete(). Show Answer Correct Answer: A) Remove(). 15. What is the purpose of the 'with' statement when handling files in Python? A) The 'with' statement is necessary for writing data to a file. B) The 'with' statement is used to open files in read mode only. C) The 'with' statement is used to ensure proper resource management when handling files. D) The 'with' statement is used to create a new file automatically. Show Answer Correct Answer: C) The 'with' statement is used to ensure proper resource management when handling files. 16. Which functions is used to write all the characters? A) Write(). B) Writecharacters(). C) Writeall(). D) Writechar(). Show Answer Correct Answer: A) Write(). 17. How many file objects would you need to manage the following situations:(a) to process four files sequentially (b) To process two sorted files into third file A) 4, 3. B) 3, 4. C) 2, 4. D) 4, 2. Show Answer Correct Answer: A) 4, 3. 18. If mode argument not passed, then Python will assume it to be ..... by default A) W. B) R+. C) R. D) W+. Show Answer Correct Answer: C) R. 19. Which statement(s) is/are true to open a binary file "Record.dat" for reading and writing? A) File =open("Record.dat", "wb"). B) File =open("Record.dat", "rb"). C) File =open("Record.dat", "ab"). D) File =open("Record.dat", "rb+"). Show Answer Correct Answer: D) File =open("Record.dat", "rb+"). 20. Name the error which occurs if the file does not exist when it is opened in 'r' mode A) I/OError. B) EOFError. C) FileNotFoundError. D) Unexpectederror. Show Answer Correct Answer: C) FileNotFoundError. 21. If there is fopen function in program then there should always be A) Fread() . B) Fwrite(). C) Fclose(). D) None. Show Answer Correct Answer: C) Fclose(). 22. How do you release dynamically allocated memory in C using free()? A) ReleaseMemory(ptr);. B) DeleteMemory(ptr);. C) Free(ptr);. D) Delete(ptr);. Show Answer Correct Answer: C) Free(ptr);. 23. What is the difference between FileWriter and Fileoutputstream in Java? A) FileWriter is used to read bytes from a file, while FileOutputStream is used to write characters to a file. B) FileWriter and FileOutputStream are not related to file handling in Java. C) FileWriter is used to write characters to a file, while FileOutputStream is used to write bytes to a file. D) FileWriter and FileOutputStream are used interchangeably in Java. Show Answer Correct Answer: C) FileWriter is used to write characters to a file, while FileOutputStream is used to write bytes to a file. 24. The ..... statement is a statement which combines the opening of your file and the processing of a file along multiple exception handling. A) Seek. B) Try. C) With. D) Load. Show Answer Correct Answer: C) With. 25. When should you use the flush() function in Python file handling? A) 3. Use file buffering. B) 2. Use file pointers. C) 1. Use file streams. D) When you want to ensure that all the data written to a file is physically saved on the disk immediately without waiting for the buffer to fill up. Show Answer Correct Answer: D) When you want to ensure that all the data written to a file is physically saved on the disk immediately without waiting for the buffer to fill up. ← 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