This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 8 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 8 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What are the different file modes in Python? A) R, w, a, x, t, b. B) C. C) W+. D) R. Show Answer Correct Answer: A) R, w, a, x, t, b. 2. Which symbols are used to open and close a list? A) ( ) round brackets. B) ( ) curly brackets. C) [ ] square brackets. D) '' '' speech marks. Show Answer Correct Answer: C) [ ] square brackets. 3. What method would you use to write multiple lines to a file at once? A) Use the 'append()' method. B) Use the 'flush()' method. C) Use the 'writelines()' method. D) Use the 'write()' method. Show Answer Correct Answer: C) Use the 'writelines()' method. 4. What is the purpose of the EOF character in a file? A) To indicate the start of the file. B) To store metadata. C) To mark the end of the file. D) To point to the next file. Show Answer Correct Answer: C) To mark the end of the file. 5. The difference between r+ and w+ modes is expressed as? A) No difference. B) In r+ mode, the pointer is initially placed at the beginning of the file and the pointer is at the end for w+. C) In w+ mode, the pointer is initially placed at the beginning of the file and the pointer is at the end for r+. D) Depends on the operating system. Show Answer Correct Answer: B) In r+ mode, the pointer is initially placed at the beginning of the file and the pointer is at the end for w+. 6. What does the program that performs file position and seek operations do? A) Prints the character at position 5. B) Writes data to the file. C) Checks for end of file. D) Opens a file. Show Answer Correct Answer: A) Prints the character at position 5. 7. Choose the CORRECT exceptionString department="JTMK"; Integer no=Integer.parseInt(department); A) ArithmeticException. B) NullPointerException. C) NumberFormatException. D) ArrayIndexOutOfBoundsException. Show Answer Correct Answer: C) NumberFormatException. 8. The reason for using pointers in a C program is A) Pointers allow different functions to share and modify their. B) To pass large structures so that complete copy of the structure can be avoided. C) Pointers enable complex "linked" data structures like linked lists and binary trees. D) All of the above. Show Answer Correct Answer: D) All of the above. 9. What is the output of the following code?file = open('data.txt', 'w')file.write('Hello, World!')file.close() A) Data.txt. B) FileNotFoundError. C) None. D) Hello, World!. Show Answer Correct Answer: C) None. 10. What is the purpose of the 'flush' method in file handling? A) The 'flush' method reads data from the file into memory. B) The 'flush' method deletes all data from the file. C) The 'flush' method ensures that all buffered data is written to the file. D) The 'flush' method closes the file after writing. Show Answer Correct Answer: C) The 'flush' method ensures that all buffered data is written to the file. 11. Why is it important to close a file after writing to it? A) To delete the file. B) To prevent the operating system from thinking the file is still open. C) To avoid file corruption. D) To save memory. Show Answer Correct Answer: B) To prevent the operating system from thinking the file is still open. 12. What is the correct declaration? A) Struct \{int a\}; s;. B) Struct s \{int a\}; s;. C) Struct s\{int a\};. D) All valid. Show Answer Correct Answer: D) All valid. 13. The readlines() method returns A) Str. B) A list of lines. C) A list of single charecters. D) A list of integers. Show Answer Correct Answer: B) A list of lines. 14. What is the last action that must be performed on a file? A) Close. B) Save. C) End. D) Write. Show Answer Correct Answer: A) Close. 15. What is the purpose of the with statement when working with files in Python? A) It ensures that the file is closed after its block of code is executed. B) It allows multiple files to be opened at once. C) It prevents the file from being deleted. D) It reads the entire file into memory. Show Answer Correct Answer: A) It ensures that the file is closed after its block of code is executed. 16. What is an absolute path? A) A path that always begins with the root folder. B) A path that is relative to the program's current working directory. C) All the above. D) None of the above. Show Answer Correct Answer: A) A path that always begins with the root folder. 17. What is the output of the program in Program 13.4? A) The record is 2222222222. B) Error in file opening. C) Total is 0. D) The record is 1111111111. Show Answer Correct Answer: A) The record is 2222222222. 18. The regular text file have-extension A) .csv. B) .ini. C) .rtf. D) .txt. Show Answer Correct Answer: D) .txt. 19. Which of the following classes define in java.io and used for file handling are abstract?i) Readerii) FileWriteriii) InputStreamiv) FileInputStreamv) PrintStream A) I, iv & v. B) Only i. C) I & iii both. D) Ii, iii & v. Show Answer Correct Answer: C) I & iii both. 20. Close the file with fclose() function. A) Yes. B) No. C) Can be yes or no. D) Can not say. Show Answer Correct Answer: A) Yes. 21. Public class X \{ public static void main(String [] args) \{ try \{ badMethod(); System.out.print("A"); \} catch (RuntimeException ex) /* Line 10 */ \{ System.out.print("B"); \} catch (Exception ex1) \{ System.out.print("C"); \} finally \{ System.out.print("D"); \} System.out.print("E"); \} public static void badMethod() \{ throw new RuntimeException(); \} \} A) BD. B) BDE. C) BD. D) DE. Show Answer Correct Answer: B) BDE. 22. What is the purpose of fprintf()? A) Reads formatted input from a file. B) Writes formatted output to a file. C) Checks for end of file. D) Deletes a file. Show Answer Correct Answer: B) Writes formatted output to a file. 23. Which mode opens a file for reading only? A) R. B) W. C) X. D) A. Show Answer Correct Answer: A) R. 24. Is block parameter in flock() optional A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 25. Which mode is used to open the binary file for writing? A) 'w'. B) 'rb'. C) 'a'. D) 'wb'. Show Answer Correct Answer: D) 'wb'. ← 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 9Class 11 Computer Science Chapter 6 File Handling Quiz 10Class 11 Computer Science Chapter 6 File Handling Quiz 11 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books