This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 16 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 16 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What parameter is used to append to a file in Python? A) B. B) A. C) R. D) W. Show Answer Correct Answer: B) A. 2. What is the purpose of the program described in the video? A) To write data to a text file. B) To create a connection between two programs. C) To play a text-based game. D) To demonstrate basic file handling operations. Show Answer Correct Answer: D) To demonstrate basic file handling operations. 3. ..... to read the remaining lines of the file from a file object infi we use ..... A) Infi.readline(). B) Infi.readlines(). C) Infi.read(). D) Infi.read(all). Show Answer Correct Answer: B) Infi.readlines(). 4. The sys.stdout is always opened in ..... mode. A) Read. B) Write. C) Append. D) Read and Write. Show Answer Correct Answer: B) Write. 5. An ..... allows multiple items to be stored under one variable name, this reduces the need for multiples variables. A) Variable. B) Array. C) Constant. D) None of the above. Show Answer Correct Answer: B) Array. 6. What is the output of the divmod(15, 4) function in Python? A) 3.75. B) (4, 3). C) 4. D) (3, 1). Show Answer Correct Answer: D) (3, 1). 7. Which of the following is nor a proper file access mode? A) Read. B) Close. C) Write. D) Append. Show Answer Correct Answer: B) Close. 8. What type of loop is ideal for processing a file when the number of lines is unknown? A) Count controlled loop. B) Nested loop. C) Infinite loop. D) Condition-controlled loop. Show Answer Correct Answer: D) Condition-controlled loop. 9. Which of the following is not an exception handling keyword in Python? A) Accept. B) Finally. C) Try. D) Except. Show Answer Correct Answer: A) Accept. 10. What must be provided to the 'open()' function to successfully open a file? A) The file's name including its file extension. B) The file's size. C) The file's creation date. D) The file's read/write speed. Show Answer Correct Answer: A) The file's name including its file extension. 11. What is the purpose of the delimiter in CSV files? A) To format the text in bold. B) To add color to the file. C) To separate individual fields or columns within each row. D) To encrypt the data. Show Answer Correct Answer: C) To separate individual fields or columns within each row. 12. It opens the file for a write. A) Ios::app. B) Ios::ate. C) Ios::in. D) Ios::trunc. E) Ios::out. Show Answer Correct Answer: E) Ios::out. 13. What are the advantages of using segmentation over paging? A) Segmentation requires less overhead for memory allocation. B) Segmentation offers better memory utilization, easier management of variable-sized data, and allows for sharing of segments. C) Paging simplifies the process of data sharing between processes. D) Paging allows for faster access to data blocks. Show Answer Correct Answer: B) Segmentation offers better memory utilization, easier management of variable-sized data, and allows for sharing of segments. 14. What is the default mode to open a text file? A) W. B) A. C) R. D) R+. Show Answer Correct Answer: C) R. 15. What is an exception A) Simply an Error. B) Error occurred during the execution of a program. C) Bug occurred during the compile time of a program. D) It is related to input values. Show Answer Correct Answer: B) Error occurred during the execution of a program. 16. Which one of the following methods is used to recuperating prepared statements resources? A) Close(). B) Final(). C) Finish(). D) End(). Show Answer Correct Answer: A) Close(). 17. The main goal of file handling in python is- A) To save program codes. B) To store state of the program. C) To save program related data. D) None. Show Answer Correct Answer: C) To save program related data. 18. What does the 'Path()' function in the pathlib module do? A) Creates a new file. B) Joins file paths using the correct separators. C) Deletes a file. D) Reads the contents of a file. Show Answer Correct Answer: B) Joins file paths using the correct separators. 19. Which method is used to close a file? A) Close(). B) Finish(). C) End(). D) Stop(). Show Answer Correct Answer: A) Close(). 20. What data type must be used when reading or writing lines in a text file? A) FLOAT. B) INTEGER. C) BOOLEAN. D) STRING. Show Answer Correct Answer: D) STRING. 21. What is the first step in handling files in C++? A) Writing to the file. B) Closing the file. C) Opening the file. D) Reading the file. Show Answer Correct Answer: C) Opening the file. 22. How to create our own exception A) Using 'throw' keyword. B) Using 'throws' keyword. C) Using 'finally' keyword. D) Using 'throwable' keyword. Show Answer Correct Answer: A) Using 'throw' keyword. 23. This method returns an integer that specifies the current position of the file object (file pointer). A) Tell(). B) Load(). C) Seek(). D) Position(). Show Answer Correct Answer: A) Tell(). 24. The ..... device print to display. A) Stdout. B) Stdin. C) Stderr. D) None of this. Show Answer Correct Answer: A) Stdout. 25. 'a' mode adds new data to the end of a file A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: A) TRUE. 26. To read the entire contents of a text file as a string from a file object fobj, the correct syntax is ..... A) Fobj.read(). B) Fobj.read(all). C) Fobj.readlines(). D) Fobj.readline(18). Show Answer Correct Answer: A) Fobj.read(). 27. Apa yang dimaksud dengan "file handling" ? A) Proses menghapus file. B) Proses mengelola dan memanipulasi data dalam file. C) Proses membaca data dari memori. D) Proses menulis data ke layar. Show Answer Correct Answer: B) Proses mengelola dan memanipulasi data dalam file. 28. This Function write data in the file in the form of list A) Writelines(). B) Writelist(). C) Write(). D) Writeline(). Show Answer Correct Answer: A) Writelines(). 29. Storing the data in binary files is called . A) Pickling. B) Unpickling. C) Both a and b. D) None. Show Answer Correct Answer: A) Pickling. 30. How do you use file streams in C++? A) By including the header and using the read and write functions. B) By including the header and using classes like ifstream for input and ofstream for output. C) By using the header and the cin and cout objects. D) By using the header and the fopen and fclose functions. Show Answer Correct Answer: B) By including the header and using classes like ifstream for input and ofstream for output. 31. Processing of Text file is faster than binary files.(T/F) A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 32. How do you create a new file using the File class in Java? A) File.createNewFile(). B) File.createFile(). C) File.addNewFile(). D) File.makeNewFile(). Show Answer Correct Answer: A) File.createNewFile(). 33. What is a text file? A) A file that contains only formatted information. B) A file with images and videos. C) A file used exclusively for Python programming. D) A file that has only information in it without any formatting. Show Answer Correct Answer: D) A file that has only information in it without any formatting. 34. Which of the following file modes is best for adding new data to the end of an existing file without overwriting its contents? A) "w" (write mode). B) "x" (exclusive creation mode). C) "r" (read mode). D) "a" (append mode). Show Answer Correct Answer: D) "a" (append mode). 35. 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. 36. A programmer want to read and write a file fastly. He want to use ..... file. A) Delimited text file. B) Text file. C) Binary File. D) CSV File. Show Answer Correct Answer: C) Binary File. 37. 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"). 38. 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. 39. To read the remaining lines of the file from object fobj, we use: A) Fobj.read(). B) Fobj.read(2). C) Fobj.readline(). D) Fobj.readlines(). Show Answer Correct Answer: D) Fobj.readlines(). 40. What is the difference between r+ and w+ modes? A) No difference. B) 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 . C) Depends on the Operating system. D) 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 . Show Answer Correct Answer: B) 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 . 41. 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. 42. Apa yang harus dilakukan sebelum menulis data ke file? A) Membaca data dari file. B) Menghapus file. C) Membuka file dengan mode yang sesuai. D) Menutup file. Show Answer Correct Answer: C) Membuka file dengan mode yang sesuai. 43. Which of the following is NOT a valid file access mode? A) APPEND. B) DELETE. C) WRITE. D) READ. Show Answer Correct Answer: B) DELETE. 44. Which method is used to write multiple lines to a file in Python? A) Write lines(). B) Writelines(). C) Append lines(). D) Write multiple(). Show Answer Correct Answer: B) Writelines(). 45. Which of the following is used to open a file in Python? A) Open(). B) Fileopen(). C) Fopen(). D) Readfile(). Show Answer Correct Answer: A) Open(). 46. Myfile=open ( "one.txt" )-here myfile is indicating ..... A) Mode. B) File object. C) File. D) Cursor. Show Answer Correct Answer: B) File object. 47. What is the correct way to open a file for both reading and writing in C++? A) File.open(filename, ios::read | ios::write). B) File.open(filename, ios::open | ios::close). C) File.open(filename, ios::write | ios::append). D) File.open(filename, ios::in | ios::out). Show Answer Correct Answer: D) File.open(filename, ios::in | ios::out). 48. 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. 49. 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. 50. 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. 51. What function is used to read the entire content of a file in Python? A) Load(). B) Get content(). C) Read(). D) Fetch(). Show Answer Correct Answer: C) Read(). 52. 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). 53. What is the default mode used by the open() function in Python when no mode is specified? A) R. B) A. C) W. D) Rb. Show Answer Correct Answer: A) R. 54. .py .java .c are ..... A) Tabular files. B) Document files. C) Web standard file. D) Source file. Show Answer Correct Answer: D) Source file. 55. 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. 56. The mode 'w+' means: A) Write + Read (overwrite). B) Read + Append. C) Append only. D) Write only. Show Answer Correct Answer: A) Write + Read (overwrite). 57. How many except statements can a try-except statement have? A) None. B) One. C) Two. D) Multiple. Show Answer Correct Answer: D) Multiple. 58. What does fscanf() do? A) Writes formatted output to a file. B) Resets the file position to the beginning. C) Checks for file errors. D) Reads formatted input from a file. Show Answer Correct Answer: D) Reads formatted input from a file. 59. What function is used to close a file in Python? A) Terminate(). B) Close(). C) End(). D) Finish(). Show Answer Correct Answer: B) Close(). 60. If a CSV file contains header row, which function is used to skip it? A) Next(reader). B) Skipheader(). C) Passheader(). D) Reader.next(). Show Answer Correct Answer: A) Next(reader). ← PreviousNext →Related 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