This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 21 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 21 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What type of data does the 'write' function handle in binary file operations? A) Text data only. B) Integer data only. C) Character data only. D) Data in its original format. Show Answer Correct Answer: D) Data in its original format. 2. Which function open file in python? A) Open(). B) New(). C) All the above. D) None of the above. Show Answer Correct Answer: A) Open(). 3. Which function is used to explicitly close an opened file in C? A) Fread(). B) Fopen(). C) Fwrite(). D) Fclose(). Show Answer Correct Answer: D) Fclose(). 4. Defined a statement with default value calculate(principle, rate, interest) which is the correct statement A) Calculate(principle=400, rate=250). B) Calculate(principle, rate, interest=.25). C) Calculate(principal=600, rate=250, interest=.5). D) Calculate(). Show Answer Correct Answer: C) Calculate(principal=600, rate=250, interest=.5). 5. How do you handle exceptions when working with file operations? A) Ignore exceptions and continue processing files. B) Log errors to a file without handling them. C) Use try-except blocks to catch and handle exceptions during file operations. D) Always delete the file if an error occurs. Show Answer Correct Answer: C) Use try-except blocks to catch and handle exceptions during file operations. 6. Which line would write a score to a file A) File.writeLine(scores[x]). B) File.writeLine(username[x]). C) File.readLine(username[x]). D) File.readLine(scores[x]). Show Answer Correct Answer: A) File.writeLine(scores[x]). 7. What command can you use to separate parts of a line? A) Separate(). B) Split(). C) Divide(). D) Cut(). Show Answer Correct Answer: B) Split(). 8. What does 'rb' mean in open()? A) Read text. B) Read binary. C) Read in reverse. D) Reboot file. Show Answer Correct Answer: B) Read binary. 9. What happens when a file is opened in read mode which is in fact not existing? A) File is automatically created. B) Error raised. C) Let's the user create one. D) A test file is automatically created. Show Answer Correct Answer: B) Error raised. 10. In Python, which file the user cannot able to read ..... A) Binary File. B) CSV File. C) Text File. D) Data Files. Show Answer Correct Answer: A) Binary File. 11. What is CPU scheduling and why is it necessary? A) CPU scheduling is used to enhance network security protocols. B) CPU scheduling is a technique for managing disk space allocation. C) CPU scheduling is essential for managing process execution and optimizing system performance. D) CPU scheduling is a method for increasing memory usage efficiency. Show Answer Correct Answer: C) CPU scheduling is essential for managing process execution and optimizing system performance. 12. Which function read single line at a time? A) Read(). B) Read(n). C) Readline(). D) Readlines(). Show Answer Correct Answer: C) Readline(). 13. How can data be retrieved into a program after it has been previously saved and closed? A) By restarting the computer. B) By loading the data back into the program. C) By emailing the data to oneself. D) By creating a new data file. Show Answer Correct Answer: B) By loading the data back into the program. 14. ..... and ..... are the two objects associated with the csv module to reading and write onto a CSV file. A) Reader() and writer(). B) Read() and write(). C) Dump() and load(). D) Write() and writelines(). Show Answer Correct Answer: A) Reader() and writer(). 15. What is exception handling? A) A way to anticipate and handle errors. B) A way to restrict the values a user can enter. C) A way to prevent the program from crashing if an error occurs. D) A way to check for invalid input or values. Show Answer Correct Answer: C) A way to prevent the program from crashing if an error occurs. 16. Which of the following class is used for input and output operation when working with bytes? A) InputStream. B) Writer. C) Reader. D) All of given. Show Answer Correct Answer: A) InputStream. 17. What is always one of the aims for a developer creating a program? A) Memorize large texts. B) Decompose tasks into sub-tasks. C) Learn a new language. D) Create visual art. Show Answer Correct Answer: B) Decompose tasks into sub-tasks. 18. Which of the following function is used to write data in the text file. A) Dump(). B) Load(). C) Write(). D) Output(). Show Answer Correct Answer: C) Write(). 19. How is the 'fstream' class different from 'ifstream' and 'ofstream'? A) It can read and write files. B) It can only write files. C) It is used for binary files only. D) It can only read files. Show Answer Correct Answer: A) It can read and write files. 20. What is the code to open a file named as Sample and append output to the end of this file? A) Open("Sample.dat", "ios.app"). B) Open("Sample.dat", ios::app). C) Open("ios.app", "Sample.dat"). D) Open(ios::app, "Sample.dat"). Show Answer Correct Answer: B) Open("Sample.dat", ios::app). 21. How to open a file safely for reading? A) File = open('file.txt'). B) With open('file.txt') as file. C) Open('file.txt', 'w'). D) File = file('file.txt'). Show Answer Correct Answer: B) With open('file.txt') as file. 22. Files have two modes of operation-read from and write to. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 23. How can you read binary data from a file in Python? A) Use open('filename', 'rb') to read binary data from a file. B) Read binary data using open('filename', 'wt') method. C) Use open('filename', 'text') to read binary data from a file. D) Use open('filename', 'r') to read binary data from a file. Show Answer Correct Answer: A) Use open('filename', 'rb') to read binary data from a file. 24. How do you close a file after reading or writing in Python? A) Close(file). B) File.stop(). C) File.close(file). D) File.close(). Show Answer Correct Answer: D) File.close(). 25. What is the method used to read the entire content of a file in Python? A) File.load(). B) File.read all(). C) File.open(). D) File.read(). Show Answer Correct Answer: D) File.read(). ← 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