This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 40 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 40 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which of the following file modes is best for adding new data to the end of an existing file without overwriting its contents? A) "a" (append mode). B) "w" (write mode). C) "r" (read mode). D) "x" (exclusive creation mode). Show Answer Correct Answer: A) "a" (append mode). 2. Assertion:CSV is a file format for data storage which looks like a text file. Reason:The information is organized with one record on each line and each field is separated by comma. A) Both A and R are true and R is the correct explanation of A. B) Both A and R are true and R is not the correct explanation of A. C) A is true but R is false (or partly true). D) A is false (or partly true) but R is true. Show Answer Correct Answer: A) Both A and R are true and R is the correct explanation of A. 3. A programmer want to read and write a file fastly. He want to use ..... file. A) Delimited text file. B) CSV File. C) Binary File. D) Text file. Show Answer Correct Answer: C) Binary File. 4. We want to write something in test.txt file. what is the correct syntax? A) F = open("test.txt", "w"). B) F = open("test.txt"). C) F = open("test.txt", "r"). D) None of the above. Show Answer Correct Answer: A) F = open("test.txt", "w"). 5. What does the parent attribute of a Path object return? A) The folder that contains the file. B) The name of the file. C) All the above. D) None of the above. Show Answer Correct Answer: A) The folder that contains the file. 6. To read the remaining lines of the file from object fobj, we use: A) Fobj.read(2). B) Fobj.read(). C) Fobj.readline(). D) Fobj.readlines(). Show Answer Correct Answer: D) Fobj.readlines(). 7. What is the difference between r+ and w+ modes? A) No difference. B) In case of r+ mode, if file not exists it will create a new file . Whereas in w+ mode, if file not exists, it will raise an error . C) In case of r+ mode, if file not exists it will raise an error . Whereas in w+ mode, it will create a new file, if it does not exist . D) Depends on the Operating system. Show Answer Correct Answer: C) In case of r+ mode, if file not exists it will raise an error . Whereas in w+ mode, it will create a new file, if it does not exist . 8. What is the expected output when passing 2 and 3 to the add ..... two function? A) 5. B) 6. C) Error. D) None. Show Answer Correct Answer: A) 5. 9. Apa yang harus dilakukan sebelum menulis data ke file? A) Membaca data dari file. B) Membuka file dengan mode yang sesuai. C) Menutup file. D) Menghapus file. Show Answer Correct Answer: B) Membuka file dengan mode yang sesuai. 10. Which of the following is NOT a valid file access mode? A) WRITE. B) READ. C) DELETE. D) APPEND. Show Answer Correct Answer: C) DELETE. 11. Which method is used to write multiple lines to a file in Python? A) Writelines(). B) Write multiple(). C) Write lines(). D) Append lines(). Show Answer Correct Answer: A) Writelines(). 12. Which of the following is used to open a file in Python? A) Fileopen(). B) Open(). C) Fopen(). D) Readfile(). Show Answer Correct Answer: B) Open(). 13. Myfile=open ( "one.txt" )-here myfile is indicating ..... A) File. B) File object. C) Cursor. D) Mode. Show Answer Correct Answer: B) File object. 14. What is the correct way to open a file for both reading and writing in C++? A) File.open(filename, ios::in | ios::out). B) File.open(filename, ios::read | ios::write). C) File.open(filename, ios::open | ios::close). D) File.open(filename, ios::write | ios::append). Show Answer Correct Answer: A) File.open(filename, ios::in | ios::out). 15. How can you catch multiple exceptions in a single try block? A) Use 'try-except' without specifying exception types. B) Catch exceptions by using 'finally' block only. C) Use 'except ExceptionType1 or ExceptionType2:' to catch multiple exceptions. D) Use 'except (ExceptionType1, ExceptionType2) as e:' to catch multiple exceptions. Show Answer Correct Answer: D) Use 'except (ExceptionType1, ExceptionType2) as e:' to catch multiple exceptions. 16. What is the difference between binary and text file modes? A) Text files can only contain numbers and symbols. B) Binary files store data in raw format; text files store data as readable characters. C) Binary files are easier to read than text files. D) Binary files are always larger than text files. Show Answer Correct Answer: B) Binary files store data in raw format; text files store data as readable characters. 17. What is the difference between appending and writing to a file? A) Appending adds data at the end of the file, while writing overwrites existing data. B) Appending deletes data, while writing updates data. C) Appending updates data, while writing retrieves data. D) Appending adds data, while writing retrieves and updates data. Show Answer Correct Answer: A) Appending adds data at the end of the file, while writing overwrites existing data. 18. Which mode is used to open a file for both reading and writing in Python? A) Rw. B) W+. C) R+. D) A+. Show Answer Correct Answer: C) R+. 19. What function is used to read the entire content of a file in Python? A) Get content(). B) Read(). C) Fetch(). D) Load(). Show Answer Correct Answer: B) Read(). 20. Which function is used to open a file A) Fopen(filename, mode of opening file). B) Fopen(file, mode of reading file). C) Open(filename, mode of opening file). D) None. Show Answer Correct Answer: A) Fopen(filename, mode of opening file). 21. What is the default mode used by the open() function in Python when no mode is specified? A) W. B) R. C) A. D) Rb. Show Answer Correct Answer: B) R. 22. .py .java .c are ..... A) Tabular files. B) Document files. C) Web standard file. D) Source file. Show Answer Correct Answer: D) Source file. 23. What is a potential consequence of not closing a file in a program? A) The data might not be properly saved to the file. B) The program might use more memory than necessary. C) Other programs might not be able to open the file. D) All of the above. Show Answer Correct Answer: D) All of the above. 24. The mode 'w+' means: A) Write only. B) Write + Read (overwrite). C) Read + Append. D) Append only. Show Answer Correct Answer: B) Write + Read (overwrite). 25. How many except statements can a try-except statement have? A) None. B) One. C) Two. D) Multiple. Show Answer Correct Answer: D) Multiple. ← 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