This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 3 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 3 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. How can you handle exceptions when working with binary files? A) Use print statements to debug binary file operations. B) Always read binary files in text mode. C) Ignore exceptions when working with binary files. D) Use try-except blocks to catch exceptions like IOError or EOFError when working with binary files. Show Answer Correct Answer: D) Use try-except blocks to catch exceptions like IOError or EOFError when working with binary files. 2. What is the purpose of using a list for records in Python? A) To store only numbers. B) To store different data types. C) To store only strings. D) To store only functions. Show Answer Correct Answer: B) To store different data types. 3. Which function is used to write a list of Strings in a file? A) Writelines(). B) Writefullline(). C) Writeline(). D) Writestatement(). Show Answer Correct Answer: A) Writelines(). 4. Explain the difference between read() and readline() in Python file handling. A) Read() reads the whole file at once; readline() reads one line at a time. B) Read() is used for binary files; readline() is used for text files. C) Read() reads one line at a time; readline() reads the whole file at once. D) Read() reads a specified number of bytes; readline() reads the entire file. Show Answer Correct Answer: A) Read() reads the whole file at once; readline() reads one line at a time. 5. Why is it important to close a file after operations are completed? A) To save changes to the file. B) To free up system resources. C) All of the above. D) To prevent data corruption. Show Answer Correct Answer: B) To free up system resources. 6. In binary file, there is no delimiter for a line. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 7. In pseudocode, how do you append data to a file? A) 'WRITE data TO file'. B) 'APPEND data TO file'. C) 'READ data FROM file'. D) 'OPEN file FOR APPEND'. Show Answer Correct Answer: D) 'OPEN file FOR APPEND'. 8. Reading from a file often involves using ..... A) A loop. B) An condition. C) Comments. D) None of the above. Show Answer Correct Answer: A) A loop. 9. Which of the following is used to open a file in read mode? A) Rd. B) Read. C) S. D) R. Show Answer Correct Answer: D) R. 10. To read 2 characters from a file object fobj, the command should be: A) Fobj.read(2). B) Fobj.read(). C) Fobj.readline(). D) Fobj.read2(). Show Answer Correct Answer: A) Fobj.read(2). 11. Discuss the different modes used for opening a file in Python. A) Different modes used for opening a file in Python are 'r', 'w', 'a', 'r+', 'w+', and 'a+'. B) Z. C) Y. D) X. Show Answer Correct Answer: A) Different modes used for opening a file in Python are 'r', 'w', 'a', 'r+', 'w+', and 'a+'. 12. Which mode should be specified in the 'open()' function when you need to write to a file? A) "r". B) "w". C) "a". D) "x". Show Answer Correct Answer: B) "w". 13. Which class in Java is used for file handling? A) BufferedReader. B) File. C) FileReader. D) Scanner. Show Answer Correct Answer: B) File. 14. Fflush(NULL) flushes all ..... A) Input streams. B) Output streams. C) Appended text. D) Previous contents. Show Answer Correct Answer: B) Output streams. 15. In file handling, what do the terms "r" and "a" stand for? A) Read, append. B) Append, read. C) Write, append. D) None of these. Show Answer Correct Answer: A) Read, append. 16. What is the purpose of a module in Python? A) To define a function. B) To group related functions and variables into a file. C) To execute Python scripts automatically. D) To document Python code. Show Answer Correct Answer: B) To group related functions and variables into a file. 17. Which mode is used to open a file for appending in Python? A) 'a'. B) 'r'. C) 'w'. D) 'x'. Show Answer Correct Answer: A) 'a'. 18. ..... class provides the capability to read primitive data types from an input stream. A) DataInputStream. B) PushbackInputStream. C) PipeInputStream. D) BufferedInputStream. Show Answer Correct Answer: A) DataInputStream. 19. Best way to calculate total from numeric column in CSV? A) Int(row["Column"]) inside loop. B) Add directly as strings. C) Use .split(", ") always. D) Count commas. Show Answer Correct Answer: A) Int(row["Column"]) inside loop. 20. What are the different types of function arguments in Python? A) Immutable arguments. B) Static arguments. C) Named arguments only. D) Positional arguments, keyword arguments, default arguments, variable-length arguments (*args, **kwargs), keyword-only arguments. Show Answer Correct Answer: D) Positional arguments, keyword arguments, default arguments, variable-length arguments (*args, **kwargs), keyword-only arguments. 21. Which method writes multiple lines to a file? A) Writeline(). B) Writeall(). C) Writelines(). D) Multiline(). Show Answer Correct Answer: C) Writelines(). 22. What is the purpose of the 'open' function in Python? A) To close a file after reading or writing. B) To open a file and return a file object for reading or writing. C) To create a new file in the current directory. D) To delete a file from the system. Show Answer Correct Answer: B) To open a file and return a file object for reading or writing. 23. Which function is used to close a file in C++ after performing file operations? A) 'close()'. B) 'exit()'. C) 'closefile()'. D) 'end()'. Show Answer Correct Answer: A) 'close()'. 24. This mode will open file with read write purpose A) R. B) W. C) R+. D) W+. Show Answer Correct Answer: C) R+. 25. Which of the following is NOT a basic operation on files? A) Opening a file. B) Reading a file. C) Renaming a file. D) Closing a file. Show Answer Correct Answer: C) Renaming a file. ← 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 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 10Class 11 Computer Science Chapter 6 File Handling Quiz 11 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books