This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 27 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 27 (27 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. How do you close a binary file in Python? A) File.quit(). B) File.end(). C) File.close(). D) File.stop(). Show Answer Correct Answer: C) File.close(). 2. Which function is used to open file? A) New(). B) Create(). C) Open(). D) None of the above. Show Answer Correct Answer: C) Open(). 3. If you want to read and write to a file, which mode should you use? A) 'r'. B) 'w'. C) 'r+'. D) 'a'. Show Answer Correct Answer: C) 'r+'. 4. How do you serialize and deserialize an object in Java? A) Use the Serializable class to write the object to a database. B) Use ObjectOutputStream to write the object to a network socket. C) Use ObjectOutput to write the object to a text file. D) Implement the Serializable interface and use ObjectOutputStream to write the object to a file, then use ObjectInputStream to read the object from the file. Show Answer Correct Answer: D) Implement the Serializable interface and use ObjectOutputStream to write the object to a file, then use ObjectInputStream to read the object from the file. 5. What will be the output of the program?try { int x = 0; int y = 5 / x; } catch (Exception e) { System.out.println("Exception"); } catch (ArithmeticException ae) { System.out.println(" Arithmetic Exception"); } System.out.println("finished"); A) Exception. B) Compilation fails. C) Finished. D) Runtime error. Show Answer Correct Answer: B) Compilation fails. 6. What is a user-defined function? A) A function provided by the programming language. B) A command that you create yourself. C) A built-in library function. D) A function that cannot be modified. Show Answer Correct Answer: B) A command that you create yourself. 7. Explain the concepts of pickling and unpickling in Python file handling. A) Pickling and unpickling are used for sorting data in Python files. B) Pickling and unpickling involve converting Python objects to JSON format. C) Pickling is used for compressing files, while unpickling is used for decompressing files. D) Pickling and unpickling in Python file handling involve converting Python objects to byte streams and vice versa. Show Answer Correct Answer: D) Pickling and unpickling in Python file handling involve converting Python objects to byte streams and vice versa. 8. ..... is itself a bunch of bytes stored on some storage device like hard disk, thumb drive etc A) File. B) Binary file. C) Text file. D) Folder. Show Answer Correct Answer: A) File. 9. While working on a group project, Abhishek and Tanisha are reading a CSV file containing data about their survey results. They want to skip the header row to directly access the data. Which of the following is the correct way to use next() to skip the header row while reading the CSV file in Python? A) Reader = csv.reader(file)csv.next(reader). B) Next(csv.reader(file)). C) Reader = csv.reader(file)next(reader). D) Reader = csv.reader(file)reader.next(). Show Answer Correct Answer: C) Reader = csv.reader(file)next(reader). 10. What does this code snippet do?with open('numbers.txt', 'r') as f:for line in f:print(line.strip()) A) Writes each line to 'numbers.txt'. B) Appends each line to 'numbers.txt'. C) Reads each line from 'numbers.txt' and prints it without trailing newline characters. D) Deletes each line from 'numbers.txt'. Show Answer Correct Answer: C) Reads each line from 'numbers.txt' and prints it without trailing newline characters. 11. Structure padding increases: A) Memory. B) Speed. C) Both. D) Neither. Show Answer Correct Answer: A) Memory. 12. What is the main advantage of using the pathlib module over os.path? A) It provides a more intuitive interface. B) It is only available in Python 3.8. C) It does not support file paths. D) It is more complex. Show Answer Correct Answer: A) It provides a more intuitive interface. 13. Apa kelebihan penggunaan context manager ketika membuka sebuah file? A) Untuk menangani error yang mungkin muncul dengan lebih baik. B) Untuk menulis file dalam format tertentu. C) Untuk membaca file dengan lebih cepat. D) Untuk menutup file secara otomatis setelah digunakan. Show Answer Correct Answer: D) Untuk menutup file secara otomatis setelah digunakan. 14. To force python to write the contents of file buffer on to storage file, ..... method may be used. A) Write(). B) Close(). C) Buffer(). D) Flush(). Show Answer Correct Answer: D) Flush(). 15. Which Tkinter widget allows users to select one option from a set? A) Checkboxes. B) Sliders. C) Dialogs. D) Radiobuttons. Show Answer Correct Answer: D) Radiobuttons. 16. Which of the following function can be used to set the file pointer at a given position A) Seek. B) Tell. C) All the above. D) None of the above. Show Answer Correct Answer: A) Seek. 17. Which file mode should be used if you need to both read from and write to the same file without deleting its contents? A) WRITE. B) READ. C) APPEND. D) READ/WRITE. Show Answer Correct Answer: D) READ/WRITE. 18. Which of the following function is used to write data in text mode? A) Dump. B) Output. C) Send. D) Write. Show Answer Correct Answer: D) Write. 19. Which of the following format of files can be created programmatically through Python to some data? A) Data files. B) Text files. C) CSV Files. D) Video files. Show Answer Correct Answer: B) Text files. 20. Which mode should be used to open a file for appending data in C++? A) Ios::in. B) Ios::app. C) Ios::out. D) Ios::trunc. Show Answer Correct Answer: B) Ios::app. 21. Which of the following codes will close a file named as Sample? A) Close(Sample);. B) Sample(close);. C) Close.Sample();. D) Sample.close();. Show Answer Correct Answer: D) Sample.close();. 22. Which of the following strings is used to open a file in read as well as write modes? A) Rwrite. B) R+. C) Rw. D) Readw. Show Answer Correct Answer: B) R+. 23. How to import python math modules? A) Form import math. B) Import from math. C) From math. D) Import math. Show Answer Correct Answer: D) Import math. 24. A Variable defined inside a function referred to as A) A Static Variable. B) A Global Variable. C) A Local variable. D) A automatic Variable. Show Answer Correct Answer: C) A Local variable. 25. To store a dictionary in a file in binary format, we use: A) Csv. B) Json. C) Dictfile. D) Pickle. Show Answer Correct Answer: D) Pickle. 26. What is the code to open a file named as Sample and remove all the previous content stored in the file? A) Open(ios::trunc, "Sample.dat"). B) Open("ios::trunc", "Sample.dat"). C) Open("Sample.dat", ios::trunc). D) Open("Sample.dat", "ios::trunc"). Show Answer Correct Answer: C) Open("Sample.dat", ios::trunc). 27. Explain how to write data to a binary file. A) Open a file in binary read mode, read the data, and close the file. B) Prepare binary data, open a file in read mode, and write it using the append method. C) Open a file in text mode, write text data, and close the file. D) Open a file in binary write mode, prepare binary data, write it using the write method, and close the file. Show Answer Correct Answer: D) Open a file in binary write mode, prepare binary data, write it using the write method, and close the file. ← PreviousRelated QuizzesScience QuizzesClass 11 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 8 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books