This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 46 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 46 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. To read 18 characters from the file object fobj, the correct syntax is ..... A) Fobj.readlines(18). B) Fobj.readchar(18). C) Fobj.read(18). D) Fobj.readline(18). Show Answer Correct Answer: C) Fobj.read(18). 2. Which function is used to read all the characters in a text file? A) Readline(10). B) Read(). C) Readall(). D) Readcharacters(). Show Answer Correct Answer: B) Read(). 3. How do you read the entire content of a text file in Python? A) Content = readfile('filename.txt'). B) Content = open('filename.txt').read(). C) Content = open('filename.txt', 'r').read(). D) Content = read('filename.txt'). Show Answer Correct Answer: C) Content = open('filename.txt', 'r').read(). 4. Which of the follwing methods is used to write() into a file? A) WriteFile(). B) Put(). C) Write(). D) Print(). Show Answer Correct Answer: C) Write(). 5. What will be the output of the following snippet? A) True. B) False. C) None. D) Error. Show Answer Correct Answer: A) True. 6. What happens when file opened in 'a' mode? A) Content is overwritten. B) Content is erased. C) New data added at the end. D) File is deleted. Show Answer Correct Answer: C) New data added at the end. 7. What will the following code snippet do?F=open("abc.txt", "a")x="class12"F.write(x)F.close() A) Writing into the file without erasing old content. B) Writing into the file by erasing old content. C) Reading from the file by erasing old content. D) Reading from the file without erasing old content. Show Answer Correct Answer: A) Writing into the file without erasing old content. 8. What happens when '1' == 1 is executed? A) We get a True. B) We get a False. C) An TypeError occurs. D) A ValueError occurs. Show Answer Correct Answer: B) We get a False. 9. Public class Foo \{ public static void main(String[] args) \{ try \{ return; \} finally \{ System.out.println( "Finally" ); \} \} \} A) Finally. B) Compilation fails. C) The code runs with no output. D) An exception is thrown at runtime. Show Answer Correct Answer: A) Finally. 10. Which exception is handled while reading binary file? A) FileNotFoundError. B) EOFError. C) OSError. D) All of these. Show Answer Correct Answer: D) All of these. 11. What does the os.makedirs() function do? A) Creates new folders. B) Deletes existing folders. C) All the above. D) None of the above. Show Answer Correct Answer: A) Creates new folders. 12. We can create our own error types in Python? A) Yes, we can create our error types in Python. B) No, we cannot define custom errors in Python. C) All the above. D) None of the above. Show Answer Correct Answer: A) Yes, we can create our error types in Python. 13. What is the correct order of operations for reading from a file in pseudocode? A) Open $\rightarrow$ Read $\rightarrow$ Close. B) Close $\rightarrow$ Open $\rightarrow$ Read. C) Read $\rightarrow$ Open $\rightarrow$ Close. D) Open $\rightarrow$ Close $\rightarrow$ Read. Show Answer Correct Answer: A) Open $\rightarrow$ Read $\rightarrow$ Close. 14. It is necessary to always create the file in the same default folder where Python has been installed. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 15. How can you check if a file exists before deleting it? A) Using os.path.exists() function. B) Using os.remove() function. C) Using open() function. D) Using close() function. Show Answer Correct Answer: A) Using os.path.exists() function. 16. The full name of a file is also called ..... A) Relative Path Name. B) Absolute path Name. C) Directory. D) Path name. Show Answer Correct Answer: D) Path name. 17. ..... function will break the link of file object and file on the disk A) Open(). B) Read(). C) Write(). D) Close(). Show Answer Correct Answer: C) Write(). 18. How do you handle exceptions in Python while working with files? A) Always ignore exceptions when working with files. B) Close the file before handling exceptions. C) Use print statements to debug file operations. D) Use try-except blocks to catch exceptions during file operations. Show Answer Correct Answer: D) Use try-except blocks to catch exceptions during file operations. 19. Which class can be used to read data line by line using readLine() method? A) DataOutputtream. B) DataInputStream. C) InputStreamReader. D) BufferedReader. Show Answer Correct Answer: D) BufferedReader. 20. Can values got from forms in html be given to php A) Sometimes. B) Yes. C) No. D) None. Show Answer Correct Answer: B) Yes. 21. Which Tkinter widget is used to create clickable elements for user interaction? A) Buttons. B) Sliders. C) Label. D) Canvas Widget. Show Answer Correct Answer: A) Buttons. 22. What will be the output of add ..... two(5, 7)? A) 12. B) 2. C) 35. D) None. Show Answer Correct Answer: A) 12. 23. The correct syntax of seek() is: A) File object.seek(offset [, reference point]). B) Seek(offset [, reference point]). C) Seek(offset, file object). D) Seek.file object(offset). Show Answer Correct Answer: A) File object.seek(offset [, reference point]). 24. How do you close a file after opening it? A) Call the 'terminate' function on the file handle. B) Use the 'close' method on the file object. C) Use the 'delete' method on the file object. D) Invoke the 'end' command on the file stream. Show Answer Correct Answer: B) Use the 'close' method on the file object. 25. Which function is used to check the file opening mode of the file? A) Readable(). B) Writable(). C) Both readable() & writable(). D) None. Show Answer Correct Answer: C) Both readable() & writable(). ← 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