This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 52 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 52 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. I want an array that stores values between 2 and 5, which of the following is correct? A) MyArray[2 to 5]. B) MyArray2 to 5. C) MyArray[5]. D) MyArray\{2 to 5\}. Show Answer Correct Answer: A) MyArray[2 to 5]. 2. Which mode truncates the file to zero length? A) "a". B) "r". C) "w". D) "r+". Show Answer Correct Answer: C) "w". 3. What function would you use to close a file in Python? A) Close(). B) End(). C) Finish(). D) Terminate(). Show Answer Correct Answer: A) Close(). 4. Which function is used to read single line from file? A) Readline(). B) Readlines(). C) Read(n). D) Readline(1). Show Answer Correct Answer: A) Readline(). 5. While appending the data to the binary file, the mode should be ..... A) 'a+'. B) 'ab'. C) 'a'. D) 'w'. E) 'w+'. Show Answer Correct Answer: B) 'ab'. 6. Which widget in Tkinter is used to display a single line of text input from the user? A) Entry Widget. B) Canvas Widget. C) Message Widget. D) Slider. Show Answer Correct Answer: A) Entry Widget. 7. What is the main purpose of file handling in programming? A) To create images. B) To save and retrieve data. C) To design websites. D) To play music. Show Answer Correct Answer: B) To save and retrieve data. 8. What is the purpose of the 'struct' module in binary file handling? A) The 'struct' module is designed for handling text files only. B) The 'struct' module provides functions for database management. C) The 'struct' module is used for creating graphical user interfaces. D) The 'struct' module facilitates the handling of binary data by providing functions to pack and unpack data into and from binary formats. Show Answer Correct Answer: D) The 'struct' module facilitates the handling of binary data by providing functions to pack and unpack data into and from binary formats. 9. Discuss the importance of error handling in file operations in Python. A) Ignoring errors in file operations leads to better performance. B) Error handling in file operations is not necessary in Python. C) Handling errors in file operations can introduce more bugs. D) Error handling in file operations is important in Python to prevent program crashes and handle exceptions gracefully. Show Answer Correct Answer: D) Error handling in file operations is important in Python to prevent program crashes and handle exceptions gracefully. 10. What happens when a piece of data is written to a file? A) Data is copied from a variable in RAM to a file. B) Data is copied from a variable in the program to a file. C) Data is copied from the program to a file. D) Data is copied from a file object to a file. Show Answer Correct Answer: A) Data is copied from a variable in RAM to a file. 11. Function used to read all the content of file in the form of list: A) Read(). B) Readline(). C) Read lines(). D) Readlines(). Show Answer Correct Answer: D) Readlines(). 12. A CSV file is also known as a A) 3D File. B) String file. C) Flat file. D) Random file. Show Answer Correct Answer: C) Flat file. 13. What is the method used to delete a file in Python? A) Os.delete(). B) File.delete(). C) Os.remove() or os.unlink(). D) Remove.file(). Show Answer Correct Answer: C) Os.remove() or os.unlink(). 14. Which are the different ways to read data from the keyboard? A) Scanner. B) InputStreamReader. C) DataInputStream. D) All of given. Show Answer Correct Answer: D) All of given. 15. What is the method used to reassign the standard input stream in Python? A) Sys.stdin.write(). B) Reassigning sys.stdin. C) Input(). D) Sys.stdin.readline(). Show Answer Correct Answer: B) Reassigning sys.stdin. 16. Fprintf() is used to write: A) Characters only. B) Strings only. C) Formatted output. D) Binary only. Show Answer Correct Answer: C) Formatted output. 17. Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist? A) 'w'. B) 'r'. C) 'a'. D) 'e'. Show Answer Correct Answer: A) 'w'. 18. How do you read a text file line by line in Python? A) Use 'open("filename.txt") as file:read(file)'. B) Use 'with open("filename.txt") as file:for line in file:print(line)'. C) Use 'file.read lines("filename.txt")'. D) Use 'open("filename.txt") and file.readlines()'. Show Answer Correct Answer: B) Use 'with open("filename.txt") as file:for line in file:print(line)'. 19. The ..... and ..... functions work identically with the text file as well as binary file A) Tell(), seek(). B) Dump(), Load(). C) Try(), Except(). D) Pickle(), Unpickle(). Show Answer Correct Answer: A) Tell(), seek(). 20. Which of the following function you can use to write data in the binary format? A) Sendbinary(). B) Loadbinary(). C) Load(). D) Dump(). Show Answer Correct Answer: D) Dump(). 21. Which method returns the absolute pathname of a file? A) GetAbsolutePath(). B) GetPath(). C) GetFullPath(). D) GetDirectory(). Show Answer Correct Answer: A) GetAbsolutePath(). 22. How do you close a file in C++? A) Terminate(). B) Finish(). C) End(). D) Close(). Show Answer Correct Answer: D) Close(). 23. Urutan langkah file yang benar menurut gambar adalah apa? A) Tutup, deklarasi, proses, buka. B) Proses, tutup, buka, deklarasi. C) Buka, proses, tutup, deklarasi. D) Deklarasi, buka, proses, tutup. Show Answer Correct Answer: D) Deklarasi, buka, proses, tutup. 24. What is the output of the following recursive function?def countdown(n):if n <= 0:print("Blastoff!")else:print(n, end=" ")countdown(n-1)countdown(5) A) Blastoff!. B) 5 4 3 2 1 Blastoff!. C) 1 2 3 4 5 Blastoff!. D) Error. Show Answer Correct Answer: B) 5 4 3 2 1 Blastoff!. 25. To close a file we use: A) Endfile(). B) Close(). C) Fclose(). D) File end(). Show Answer Correct Answer: C) Fclose(). ← 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