This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 15 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 15 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. How do you create a Fileoutputstream object in Java? A) FileOutputStream.open("filename.txt"). B) FileOutputStream.write("filename.txt"). C) FileOutputStream.create("filename.txt"). D) New FileOutputStream("filename.txt"). Show Answer Correct Answer: D) New FileOutputStream("filename.txt"). 2. Fseek(fp, 0, SEEK ..... SET) moves pointer to: A) End. B) Middle. C) Specific char. D) Beginning. Show Answer Correct Answer: D) Beginning. 3. Which Tkinter widget is used for drawing shapes and graphics? A) Canvas Widget. B) Entry Widget. C) Message Widget. D) Slider. Show Answer Correct Answer: A) Canvas Widget. 4. Which is used for writing data to a file in file handling? A) FileInputStream. B) FileOutputStream. C) Both A & B. D) None of the above. Show Answer Correct Answer: B) FileOutputStream. 5. The ..... block holds the code to be run (Run the code) checked for any error, if exists A) Try. B) Except. C) Else. D) Finally. Show Answer Correct Answer: A) Try. 6. What does two periods (dot-dot) mean in a path? A) This directory. B) The parent folder. C) All the above. D) None of the above. Show Answer Correct Answer: B) The parent folder. 7. What is the purpose of the 'a' mode when opening a file in Python? A) It indicates that the file is being opened in append mode for text data. B) It signifies that the file is being opened in read mode for binary data. C) It specifies that the file is being opened in write mode for text data. D) It signifies that the file is being opened in read mode specifically for text data. Show Answer Correct Answer: A) It indicates that the file is being opened in append mode for text data. 8. To open a file poem.txt for reading, the correct syntax is ..... A) File=open('poem.txt', 'r'). B) File=open(file='poem.txt', 'r'). C) Fileopen=('poem.txt', 'r'). D) F=('poem.txt', 'w'). Show Answer Correct Answer: A) File=open('poem.txt', 'r'). 9. What does opening a file in mode 'a' mean?with open("test.txt ", 'a') as f: A) Open test.txtfor reading. B) Open test.txtfor writing. C) Open test.txt for appending text at the end of the file. D) None of the file. Show Answer Correct Answer: C) Open test.txt for appending text at the end of the file. 10. Public class X \{ public static void main(String [] args) \{ try \{ badMethod(); System.out.print("A"); \} catch (Exception ex) \{ System.out.print("B"); \} finally \{ System.out.print("C"); \} System.out.print("D"); \} public static void badMethod() \{ throw new Error(); /* Line 22 */ \} \} A) ABCD. B) Compilation fails. C) C is printed before exiting with an error message. D) BC is printed before exiting with an error message. Show Answer Correct Answer: C) C is printed before exiting with an error message. 11. Files are having ..... nature. A) Transient. B) Dynamic. C) Sequential. D) Persistent. Show Answer Correct Answer: D) Persistent. 12. What method would you use to read all lines from a file into a list? A) File.getlines(). B) File.readlines(). C) File.fetch all(). D) File.read(). Show Answer Correct Answer: B) File.readlines(). 13. What is the primary function of a file handler in computer programming? A) To display data on the screen. B) To store the external file so that the running program can work on it. C) To manage user inputs. D) To enhance the graphical user interface. Show Answer Correct Answer: B) To store the external file so that the running program can work on it. 14. What is the result of trying to read a file that does not exist? A) The program continues without any issues. B) The system automatically creates a new file. C) An error is raised indicating the file does not exist. D) The file opens successfully with default content. Show Answer Correct Answer: C) An error is raised indicating the file does not exist. 15. What method is used to write multiple rows to a CSV file at once? A) Csv.insertrows(). B) Csv.writeall(). C) Csv.writerows(). D) Csv.addrows(). Show Answer Correct Answer: C) Csv.writerows(). 16. What does the 'with' statement do when handling files? A) The 'with' statement allows multiple files to be opened simultaneously. B) The 'with' statement requires manual file closure after use. C) The 'with' statement prevents file access errors. D) The 'with' statement automatically closes the file after its block of code is executed. Show Answer Correct Answer: D) The 'with' statement automatically closes the file after its block of code is executed. 17. A=m.read(3)Here the above code read(3) will point which pointer position ..... if the file content is ..... 12, welcome-1jio A) 2. B) ,. C) W. D) E. Show Answer Correct Answer: C) W. 18. What does file.write("Hello") do? A) Reads Hello from file. B) Writes Hello to file. C) Appends Hello. D) Deletes Hello. Show Answer Correct Answer: B) Writes Hello to file. 19. Usb stangs for A) Universal serial bus. B) Universal source bus. C) Universal secondary bus. D) Universal section bus. Show Answer Correct Answer: A) Universal serial bus. 20. How do you open a file for writing in Python? A) Open('filename.txt', 'a'). B) Open('filename.txt', 'w'). C) Open('filename.txt', 'x'). D) Open('filename.txt', 'r'). Show Answer Correct Answer: B) Open('filename.txt', 'w'). 21. Which of the following file-modes does retains file data and append new data. A) 'a+'. B) 'a'. C) 'w+'. D) 'r+'. Show Answer Correct Answer: A) 'a+'. 22. To write dictionaries, tuples and any other python objects in binary file ..... function is used A) Dump(). B) Load(). C) Write(). D) Writelines(). Show Answer Correct Answer: A) Dump(). 23. What exception is raised when trying to open a non-existent file? A) FileNotFoundError. B) NoSuchFileError. C) FileAccessError. D) FileMissingException. Show Answer Correct Answer: A) FileNotFoundError. 24. What is the outcome if you open a file in 'WRITE' mode and the file already contains data? A) The existing data is kept, and new data is added. B) The existing data is deleted, and new data is written. C) The existing data is locked. D) An error occurs. Show Answer Correct Answer: B) The existing data is deleted, and new data is written. 25. Apa tipe data yang akan dikembalikan oleh fungsi numpy.loadtxt()? A) String. B) Dictionary. C) DataFrame. D) Ndarray. Show Answer Correct Answer: D) Ndarray. ← 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