This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 58 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 58 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. How can you read a CSV file using Python's built-in libraries? A) Use the 'csv' module to read a CSV file. B) Use the 'pandas' library to read a CSV file. C) Utilize the 'xml' module to parse a CSV file. D) Read a CSV file using the 'json' module. Show Answer Correct Answer: A) Use the 'csv' module to read a CSV file. 2. What will file.read(4) do? A) Read 4 characters. B) Read 4 lines. C) Read 4 bytes. D) A and c. Show Answer Correct Answer: D) A and c. 3. Function to read the entire file A) Read(2). B) Readlines(). C) Readline(). D) All of the above. Show Answer Correct Answer: B) Readlines(). 4. To read the entire contents of the file as a string from a file object fobj, the command should be: A) Fobj.read(2). B) Fobj.read(). C) Fobj.readline(). D) Fobj.readlines(). Show Answer Correct Answer: B) Fobj.read(). 5. What will happen when you run this code:with open('data.txt', 'r') as file:print(file.read())? A) The file will close after reading. B) It will show 'data.txt'. C) It will print the text inside 'data.txt'. D) An error message will appear. Show Answer Correct Answer: C) It will print the text inside 'data.txt'. 6. Which of these class contains the methods print() & println()? A) PrintStream. B) BUfferedOutputStream. C) System.out. D) System. Show Answer Correct Answer: B) BUfferedOutputStream. 7. What is missing from this code?file = open ( "test1 ..... ", "w" ) A) Jpeg. B) Txt. C) Mp3. D) Mov. Show Answer Correct Answer: B) Txt. 8. If break statement is inside a nested loop, break will terminate the innermost loop. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 9. Class Main \{ public static void main(String args[]) \{ try \{ throw 10; \} catch(int e) \{ System.out.println("Got the Exception '' + e); \} \}\} A) Got the Exception 10. B) Got the Exception 0. C) Compiler Error. D) None. Show Answer Correct Answer: C) Compiler Error. 10. Assume that the customer file references a file object, and the file was opened using the 'w' mode specifier. How would you write the string 'Mary Smith' to the file? A) Customer file.write('Mary Smith'). B) Customer.write('w', 'Mary Smith'). C) Customer.input('Mary Smith'). D) Customer.write('Mary Smith'). Show Answer Correct Answer: D) Customer.write('Mary Smith'). 11. Every file maintains a ..... which tells the current position in the file. A) File pointer. B) Bytes. C) Cursor. D) Paths. Show Answer Correct Answer: A) File pointer. 12. Which mode should be used with pickle.load()? A) 'rb'. B) 'wb'. C) 'r'. D) 'w'. Show Answer Correct Answer: A) 'rb'. 13. What does the "t" in the mode "rt" stand for when opening a file in Python? A) Temporary. B) Text. C) Tab-delimited. D) Transfer. Show Answer Correct Answer: B) Text. 14. What is the purpose of a pointer FILE* in C? A) To store the position in memory of the beginning of a file. B) To define the type of file access. C) To create a new file. D) To close an open file. Show Answer Correct Answer: A) To store the position in memory of the beginning of a file. 15. To create the reader object, the correct syntax is ..... [Assume that the salesdet.csv file is opened in reading mode in the file handle fh. A) Salesdet reader=csv.reader(fh). B) Salesdet reader=csvreader(fh). C) Salesdet reader=csv.read(fh). D) Salesdet reader=csvreader.fh. Show Answer Correct Answer: A) Salesdet reader=csv.reader(fh). 16. What does the pathlib module do? A) Handles file paths automatically. B) Creates files. C) Deletes files. D) Changes file extensions. Show Answer Correct Answer: A) Handles file paths automatically. 17. What are file extensions? A) The part after the dot in a filename. B) The size of the file. C) The location of the file. D) The type of the operating system. Show Answer Correct Answer: A) The part after the dot in a filename. 18. What does the 'seekg' function do in file handling? A) It reads data from the file. B) It closes the file. C) It moves the read position to a specified location. D) It opens a file for writing. Show Answer Correct Answer: C) It moves the read position to a specified location. 19. What is the function of the mode ' w+'? A) Create text file for update, do not discard previous contents if any. B) Create text file for writing, discard previous contents if any. C) Create text file for update, discard previous contents if any. D) Create text file for writing, do not discard previous contents if any. Show Answer Correct Answer: C) Create text file for update, discard previous contents if any. 20. Which mode in Python is used to open a file for writing? A) W. B) A. C) R. D) X. Show Answer Correct Answer: A) W. 21. Expand BOF A) Between of file pointer. B) Behind of File. C) Beginning of file pointer. D) Beginning of File. Show Answer Correct Answer: D) Beginning of File. 22. CSV module allows writing multiple records in a CSV file using A) Writerows(). B) Writerow(). C) Writerec(). D) Writelines. Show Answer Correct Answer: A) Writerows(). 23. Which statement correctly opens a file for exclusive creation? A) F = open('file.txt', 'a'). B) F = open('file.txt', 'r'). C) F = open('file.txt', 'x'). D) F = open('file.txt', 'w'). Show Answer Correct Answer: C) F = open('file.txt', 'x'). 24. Given a text file opened as file ..... in, which of the following will print the entire file? A) Print(file in.read()). B) Print(file in.readline()). C) Print(file in.get()). D) For line in file in:print(line). Show Answer Correct Answer: A) Print(file in.read()). 25. When you open a file for reading and if the file does not exist what occurs? A) New file will be created. B) An error occurs. C) Both a and d. D) The program will open a empty file. Show Answer Correct Answer: D) The program will open a empty 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 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