This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 34 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 34 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. The output sent to the file is appended to it. A) Ios::ate. B) Ios::in. C) Ios::out. D) Ios::app. E) Ios::trunc. Show Answer Correct Answer: D) Ios::app. 2. File is created if does not exist. If the file exists, file is truncated( past data is lost). Both reading and writing operation can take place. What is the text file mode? A) 'r'. B) 'w'. C) 'w+'. D) 'a+'. Show Answer Correct Answer: C) 'w+'. 3. What does the 'read()' function do? A) Deletes the contents of a file. B) Reads all the text in a file. C) Writes text to a file. D) Closes the file. Show Answer Correct Answer: B) Reads all the text in a file. 4. Which method is used to set the file handle's position within a file? A) Tell(). B) Search(). C) Seek(). D) Search(. Show Answer Correct Answer: C) Seek(). 5. Which function is used to count or display words from a file? A) Count=count+1. B) Print(count). C) Split(). D) Len(L). Show Answer Correct Answer: C) Split(). 6. File.seek(0) followed by file.read() will: A) Re-read file from start. B) Raise error. C) Overwrite. D) Skip file. Show Answer Correct Answer: A) Re-read file from start. 7. What is the primary purpose of the close operation in file handling? A) To write data to the file. B) To read data from the file. C) To flush any unwritten data to the file and release system resources. D) To delete the file. Show Answer Correct Answer: C) To flush any unwritten data to the file and release system resources. 8. What is the first file handling operation mentioned in the text? A) Open. B) Write. C) Close. D) Read. Show Answer Correct Answer: A) Open. 9. What does the 'open' command do in Python file handling? A) It creates a new file. B) It reads the file. C) It closes the file. D) It opens the file for reading or writing. Show Answer Correct Answer: D) It opens the file for reading or writing. 10. What will be the output of the following code?def add(a, b):return a + bprint(add(5, 7)) A) 57. B) 12. C) Error. D) None. Show Answer Correct Answer: B) 12. 11. Which method is used to read the entire contents of a file in Python? A) Read(). B) Write(). C) Seek(). D) Close(). Show Answer Correct Answer: A) Read(). 12. What will be the output of the following C code#include union temp \{ int a; float b; char c; \}; int main() \{ union temp s = \{1, 2.5, 'A'\}; printf("%c", s.c); return 0; \} A) '1'. B) Compilation error. C) 'A'. D) Nothing. Show Answer Correct Answer: B) Compilation error. 13. What is the function used to read from a file in Python? A) Open(). B) Write(). C) Load(). D) Read(). Show Answer Correct Answer: A) Open(). 14. How can you read from a file in Python? A) Open('file.txt', 'r').read(). B) Open('file.txt', 'w').read(). C) Read('file.txt'). D) File.open('file.txt', 'read'). Show Answer Correct Answer: A) Open('file.txt', 'r').read(). 15. What is the function used to check if a file exists in Python? A) Os.path.exists(). B) Check.file(). C) File.exist(). D) Os.path.exist(). Show Answer Correct Answer: A) Os.path.exists(). 16. What is the significance of the 'rb' mode when opening a binary file? A) It indicates that the file is being opened in write mode for binary data. B) It signifies that the file is being opened in append mode for binary data. C) It specifies that the file is being opened in read mode for text data. D) It signifies that the file is being opened in read mode specifically for binary data. Show Answer Correct Answer: D) It signifies that the file is being opened in read mode specifically for binary data. 17. What does the 'readlines' method do in Python file handling? A) Reads every line from the file one at a time. B) Reads a specific line from the file. C) Reads a single line from the file. D) Reads the entire file at once. Show Answer Correct Answer: A) Reads every line from the file one at a time. 18. To read 4th line from text file, which of the following statement is true? A) Dt = f.readlines();print(dt[3]). B) Dt=f.read(4) ;print(dt[3]). C) Dt=f.readline(4);print(dt[3]). D) All of these. Show Answer Correct Answer: A) Dt = f.readlines();print(dt[3]). 19. What is the significance of file modes in file handling? A) File modes are significant because they control access permissions and operations on files, ensuring data integrity and appropriate handling. B) File modes dictate the file format type. C) File modes determine the size of the file. D) File modes are used to compress files for storage. Show Answer Correct Answer: A) File modes are significant because they control access permissions and operations on files, ensuring data integrity and appropriate handling. 20. Which one of these variables has an illegal name? A) $ my Var. B) $ my-Var. C) $ myVar. D) $ myVar. Show Answer Correct Answer: B) $ my-Var. 21. What does the os.path.isfile() function return if the file does not exist? A) True. B) False. C) Error. D) None. Show Answer Correct Answer: B) False. 22. Which of the following modes allows both reading and writing to a file? A) R+. B) W. C) R. D) A. Show Answer Correct Answer: A) R+. 23. Ravi opened a file in a certain mode. After opening the file, he forgot the mode. One interesting fact about that mode is '' If the file already exists, all the contents will be overwritten" . Help him to identify the correct mode. A) Read mode. B) Write mode. C) Append mode. D) Binary and read mode. Show Answer Correct Answer: B) Write mode. 24. What is the index of the last character in a string? A) 0. B) -1. C) 1. D) None of the above. Show Answer Correct Answer: B) -1. 25. What are some common use cases for binary files in programming? A) Creating web pages. B) Writing scripts for automation. C) Storing plain text files. D) Common use cases for binary files include storing images, audio files, video files, executable programs, and serialized data. Show Answer Correct Answer: D) Common use cases for binary files include storing images, audio files, video files, executable programs, and serialized data. ← 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