Class 11 Computer Science Chapter 6 File Handling Quiz 4 (60 MCQs)

Quiz Instructions

Select an option to see the correct answer instantly.

1. What is the purpose of the 'flush' method in file handling?
2. Why is it important to close a file after writing to it?
3. What is the correct declaration?
4. The readlines() method returns
5. What is the last action that must be performed on a file?
6. What is the purpose of the with statement when working with files in Python?
7. What is an absolute path?
8. What is the output of the program in Program 13.4?
9. The regular text file have-extension
10. Which of the following classes define in java.io and used for file handling are abstract?i) Readerii) FileWriteriii) InputStreamiv) FileInputStreamv) PrintStream
11. Close the file with fclose() function.
12. 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(); } }
13. What is the purpose of fprintf()?
14. Which mode opens a file for reading only?
15. Is block parameter in flock() optional
16. Which module is used to write and read binary files with objects?
17. Which function renames a file?
18. Which function is used to read data from Text File?
19. Is the following Python code valid?try:# Do somethingexcept:# Do somethingelse:# Do something
20. .... is the extension of binary files
21. What does the 'seek()' function do?
22. File opening modes for CSV files are:
23. The command that terminates the resources in use and frees the system of this program.
24. Which function is used to append data to a file in Python?
25. Dynamic allocation of struct uses:
26. Exp(), floor()belongs which module?
27. Which method is used to write data to a file in Python?
28. Using append adds data to an existing file
29. If there is no error, then what will the error() method return?
30. Try block may or may not contains catch blocks
31. Which of these keywords is not a part of exception handling?
32. What is the default mode when opening a file in Python?
33. Taran and Tanisha are discussing different file formats in Python for their data science project. They wonder what is a similarity between text files and CSV files.
34. A pointer variable can be
35. Which function of text file will read the content of the complete file?
36. Which of the following functions do you use to write data in the binary format?
37. What is the significance of file modes like 'r', 'w', and 'a'?
38. What happens each time you call the 'writeline' function?
39. What is the output of print(add ..... two(2, 's'))?
40. How do you read a CSV file using the csv module?
41. What exception is raised when trying to open a file in write mode that already exists?
42. If you open a file in 'append' mode, what can you do?
43. Apa yang terjadi jika file yang dibuka dengan mode "w" sudah ada?
44. Which mode is used to open an existing file for both reading and writing?
45. Function readline() and readlines() are both the same functions. Is the statement True or False
46. During a class project, Shaurya needs to write a single row of data to a CSV file using the csv.writer method. Which method should he use?
47. Which of the following statements correctly explain the function of seek() method?
48. How many number of text file are available in Python .....
49. What does the "w" mode do when opening a file?
50. What is the correct way to close a file in C++?
51. What is the purpose of the 'pprint.pformat()' function?
52. What is the purpose of saving data before closing a program?
53. Which of the following is an example of a recursive function?
54. Which method is used to read the entire contents of a file as a string in Python?
55. 3 Which module is used to work with binary files?
56. How do you write data to a CSV file in Python?
57. How can you open a text file in read mode in Python?
58. To count the number of words in a text file, the best approach is:
59. Afif uses fopen("log.txt", "w") to open a file and writes a log message. What will happen if log.txt already has old data inside?
60. What is the output of the program that writes to a file?