This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 26 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 26 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which mode in binary files is used to keep the previous data of an existing file along with add the new data at the end of it . A) Rb. B) A. C) Ab. D) Wb. Show Answer Correct Answer: C) Ab. 2. What might happen if you fail to close a file after operations in a program? A) The file will automatically delete itself. B) The file becomes read-only. C) The file may be corrupt or be unreadable. D) The file's content will duplicate. Show Answer Correct Answer: C) The file may be corrupt or be unreadable. 3. Which function is used to find the length of the list? A) Len(). B) Size(). C) Length(). D) None. Show Answer Correct Answer: A) Len(). 4. It opens the file for the output then moves the read and write control to the file's end. A) Ios::out. B) Ios::in. C) Ios::app. D) Ios::ate. E) Ios::trunc. Show Answer Correct Answer: D) Ios::ate. 5. The Binary file mode 'wb' represent? A) Read only. B) Append. C) Read and Write. D) Write only. Show Answer Correct Answer: D) Write only. 6. Structure variables are accessed using: A) $\rightarrow$. B) :. C) Either $\rightarrow$ or . D) . Show Answer Correct Answer: C) Either $\rightarrow$ or . 7. What are the three steps of file handling in Python? A) Read the file, Write to the file, Delete the file. B) Open the file, Process file, Close the file. C) Open the file, Read the file, Write to the file. D) Create a file, Edit a file, Save a file. Show Answer Correct Answer: B) Open the file, Process file, Close the file. 8. What is the first step to write data to a CSV file? A) Close the file. B) Open the file in 'w' mode. C) Use the csv.writer() method. D) Create a new file. Show Answer Correct Answer: B) Open the file in 'w' mode. 9. What will be the output-x=""if(!x):print("hello")else:print("bye") A) Hello. B) Bye. C) Error. D) None. Show Answer Correct Answer: A) Hello. 10. Which command reads data from an open file into a variable? A) WRITEFILE. B) READFILE. C) CLOSEFILE. D) OPENFILE. Show Answer Correct Answer: B) READFILE. 11. The syntax of seek() is:file ..... object.seek(offset [, reference ..... point]) What does reference ..... point indicate? A) Reference point indicates the starting position of the file object. B) Reference point indicates the ending position of the file object. C) Reference point indicates the current position of the file object. D) None of the above. Show Answer Correct Answer: A) Reference point indicates the starting position of the file object. 12. When writing to a file you cannot create new lines. A) False. B) True. C) All the above. D) None of the above. Show Answer Correct Answer: A) False. 13. Assertion:The file modes "r" , "w" , "a" also reveal the type of file these are being used with. Reason:The binary file modes have 'b' suffix with regular file modes. 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. 14. Which data type would you use for the quantity of stock in a shop? A) String. B) Float. C) Integer. D) Boolean. Show Answer Correct Answer: C) Integer. 15. Which method is used to retrieve or read pickled data from a binary file into a Python object? A) Read(). B) Load(). C) Open(). D) Dump(). Show Answer Correct Answer: B) Load(). 16. Which of the following statements about file paths is true? A) File paths are not case-sensitive on Windows and macOS. B) File paths must always be absolute. C) File paths are case-sensitive on all operating systems. D) File paths can only use backslashes. Show Answer Correct Answer: A) File paths are not case-sensitive on Windows and macOS. 17. Which statement is used for error handling in file operations? A) If-else. B) Try-except. C) Validate(). D) Handle(). Show Answer Correct Answer: B) Try-except. 18. Which one uses the open() function under read mode correctly and saves the file object to a variable? A) File = open("myFile.txt", "a"). B) Open("myFile.txt", "r"). C) File = open("myFile.txt", "r"). D) File = open("myFile.txt", r). Show Answer Correct Answer: C) File = open("myFile.txt", "r"). 19. Which of the following is a type of file in Python? A) All of the above. B) Binary file. C) Text file. D) Executable file. Show Answer Correct Answer: A) All of the above. 20. Let x= "Python", the output of print(x.upper()) is A) PYTHON. B) Python. C) PYTHON. D) "PYTHON". Show Answer Correct Answer: A) PYTHON. 21. What does the abspath() function do? A) Converts a relative path to an absolute path. B) Checks if a path is absolute. C) All the above. D) None of the above. Show Answer Correct Answer: A) Converts a relative path to an absolute path. 22. What will be the output of the following code snippet?f = open("abc.txt", "w")x = f.read()f.close()print (x) A) Error (Not readable). B) Error (Not writable). C) It will read all the data of the file. D) None of the above. Show Answer Correct Answer: A) Error (Not readable). 23. Which of the following is not a method of opening files? A) Append. B) Read. C) Replace. D) Write. Show Answer Correct Answer: C) Replace. 24. What is the purpose of the flush() method in Python file handling? A) To delete the file contents. B) To rename the file. C) To clear the internal buffer and write data to the file immediately. D) To increase the file size. Show Answer Correct Answer: C) To clear the internal buffer and write data to the file immediately. 25. What are the two parameters of the open() function in Python? A) File and type. B) Path and class. C) Filename and mode. D) Directory and access. Show Answer Correct Answer: C) Filename and mode. 26. Which of the following statements is true about text files? A) They can only contain numbers. B) They are always larger than binary files. C) They require special software to read. D) They can be opened in a text editor. Show Answer Correct Answer: D) They can be opened in a text editor. 27. What is the correct way to add 1 to the $ count variable? A) Count++;. B) $ count++;. C) $ count =+1. D) ++count. Show Answer Correct Answer: B) $ count++;. 28. Which type of file represent in tabular form / Record A) Binary. B) Text. C) CSV. D) All of the above. Show Answer Correct Answer: C) CSV. 29. What is the difference between writing to a file and appending to a file in Python? A) Writing to a file and appending to a file both delete the existing content. B) The difference is that writing to a file overwrites the existing content, while appending to a file adds new data at the end. C) Writing to a file and appending to a file are the same thing. D) Writing to a file adds new data at the end, while appending overwrites the existing content. Show Answer Correct Answer: B) The difference is that writing to a file overwrites the existing content, while appending to a file adds new data at the end. 30. What is the return type of fread() function in C? A) Char. B) Int. C) Size t. D) Float. Show Answer Correct Answer: C) Size t. 31. Which of the following is used to open a file in write mode? A) W. B) S. C) Wt. D) Write. Show Answer Correct Answer: A) W. 32. How many parameters does the open() function take in Python? A) One. B) Three. C) Four. D) Two. Show Answer Correct Answer: D) Two. 33. What is the syntax to read a file in Python? A) Open(file path).write(). B) Open(file path).read(). C) File.read(). D) Open(file path).readlines(). Show Answer Correct Answer: B) Open(file path).read(). 34. Which library is commonly used for Machine Learning programs in Python? A) Sci-mod. B) Math. C) Scikit-learn. D) Mach-learn. Show Answer Correct Answer: C) Scikit-learn. 35. You can use loops to write large amounts of text to a file A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: A) TRUE. 36. ASCII stands for A) American standard code for interchange information. B) American standard for information interchange. C) American standard code for intelligent interchange. D) None of the above. Show Answer Correct Answer: B) American standard for information interchange. 37. Which module is used to work with text files? A) Math module. B) Pickle module. C) No module is rquired. D) CSV module. Show Answer Correct Answer: C) No module is rquired. 38. Which mode is used to add data to an existing file? A) 'x'. B) 'w'. C) 'a'. D) 'r'. Show Answer Correct Answer: C) 'a'. 39. What does "non-volatile data storage" mean? A) Data is stored only in the CPU. B) Data is stored temporarily in RAM. C) Data is lost when the computer is turned off. D) Data can be used even when power to the computer is off. Show Answer Correct Answer: D) Data can be used even when power to the computer is off. 40. In which of the following package, Exception class exist? A) Java.util. B) Java.lang. C) Java.io. D) Java.file. Show Answer Correct Answer: B) Java.lang. 41. Which is correct way to write rows in CSV file? A) Writer.row(row). B) Writer.addrow(row). C) Writer.write(row). D) Writer.writerow(row). Show Answer Correct Answer: D) Writer.writerow(row). 42. Which method is used to read all lines from a file into a list in Python? A) Readlines(). B) Close(). C) Seek(). D) Write(). Show Answer Correct Answer: A) Readlines(). 43. EOF is an integer type defined in stdio. h and has a value ..... A) -1. B) 1. C) Null. D) 0. Show Answer Correct Answer: A) -1. 44. What is the purpose of the function fclose? A) To open a file for reading and writing. B) To create a new file. C) To determine if the file has reached the end. D) To close an open file. Show Answer Correct Answer: D) To close an open file. 45. Select the most appropriate format of tell () A) .tell():. B) .tell():. C) tell():. D) .tell(). Show Answer Correct Answer: D) .tell(). 46. What is the correct way to read a file in Python? A) Read('filename.txt'). B) Use 'with open("filename.txt", "r") as file:content = file.read()'. C) Open('filename.txt'). D) File = open('filename.txt', 'r'). Show Answer Correct Answer: B) Use 'with open("filename.txt", "r") as file:content = file.read()'. 47. Why is it best to open a file with "with" in Python? A) It automatically closes the file. B) Easier to read the code. C) Better for binary files. D) Closers to the pseudocode. Show Answer Correct Answer: A) It automatically closes the file. 48. What is the difference in path styles between Windows and macOS/Linux? A) Windows uses backslashes, macOS/Linux uses forward slashes. B) Both use backslashes. C) Both use forward slashes. D) Windows uses forward slashes, macOS/Linux uses backslashes. Show Answer Correct Answer: A) Windows uses backslashes, macOS/Linux uses forward slashes. 49. What is the process of converting a Python object structure into a byte stream to store in a binary file called? A) Unpickling. B) Serialization (Pickling). C) Appending. D) None of the above. Show Answer Correct Answer: B) Serialization (Pickling). 50. How do you close a file in C using fclose()? A) Fclose(file);. B) Close(file);. C) CloseFile(file);. D) File.close();. Show Answer Correct Answer: A) Fclose(file);. 51. When fwrite is used on already existing file the what will happen A) New contents added to previous file contents. B) Previous file contents deleted and new contents added. C) Error displayed. D) None. Show Answer Correct Answer: B) Previous file contents deleted and new contents added. 52. What is the purpose of fprintf() and fscanf() functions in C? A) Read and write characters. B) Read and write files with additional file pointer argument. C) Read and write integers. D) Read and write files. Show Answer Correct Answer: B) Read and write files with additional file pointer argument. 53. What method do we use as a clean up function, to reallocate the resources used when keeping the file object open? A) .clear(). B) .release(). C) .close(). D) .reset(). Show Answer Correct Answer: C) .close(). 54. What does the 'APPEND' mode do when a file is opened in this mode? A) Writes data to the file, overwriting any existing content. B) Deletes the content of the file. C) Adds data to the end of the file. D) Reads data from the file. Show Answer Correct Answer: C) Adds data to the end of the file. 55. Which function is used to force transfer of data from buffer to file? A) Flush(). B) Save(). C) All the above. D) None of the above. Show Answer Correct Answer: A) Flush(). 56. What does the 'A' parameter signify in the 'open' command when opening a file in Python? A) Create a new file. B) Overwrite the file. C) Add to the beginning of the file. D) Append to the end of the file. Show Answer Correct Answer: D) Append to the end of the file. 57. Function used to write data in binary format A) Write(). B) Output(). C) Dump(). D) Load(). Show Answer Correct Answer: C) Dump(). 58. Which statement is true to open a binary file "Record.txt" for writing and reading? A) File =open("Record.dat", "wr"). B) File =open("Record.dat", "w+"). C) File =open("Record.dat", "rw"). D) File =open("Record.dat", "ab"). Show Answer Correct Answer: B) File =open("Record.dat", "w+"). 59. Which function is used to read all the characters? A) Readall(). B) Readallchr(). C) Read(). D) Readcharacters(). Show Answer Correct Answer: C) Read(). 60. Class exception ..... handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } finally { System.out.print("C"); } } } A) B. B) A. C) BC. D) AC. Show Answer Correct Answer: C) BC. ← 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