This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 23 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 23 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. The first and second arguments of fopen() are A) File pointer. B) Filename, mode. C) File point. D) Mode, filename. Show Answer Correct Answer: B) Filename, mode. 2. A text file has the file extension of: A) .doc. B) .pdf. C) .txt. D) .text. Show Answer Correct Answer: C) .txt. 3. Select the correct order for processing a file. A) Type of file usage-File object-Process-Close file. B) File object-Process-Type of file usage-Close file. C) Type of file usage-Process-File object-Close file. D) Process-Type of file usage-File object-Close file. Show Answer Correct Answer: A) Type of file usage-File object-Process-Close file. 4. Why is a good idea to store data in text files? A) To reduce the amount of processing. B) To improve the efficiency of associated programs. C) To provide permanent storage. D) So it can be accessed quickly. Show Answer Correct Answer: C) To provide permanent storage. 5. Why is it important to always close files after handling them in PHP? A) To encrypt the file. B) To delete the file. C) To move the file to another location. D) To free up system resources. Show Answer Correct Answer: D) To free up system resources. 6. What does the 'r' mode signify when opening a file using fopen()? A) Create a text file for writing. B) Create a binary file for writing. C) Open a binary file for reading. D) Open a text file for reading. Show Answer Correct Answer: D) Open a text file for reading. 7. Apa arti ios::in saat membuka file? A) Menghapus isi file. B) Menulis ke file. C) Menambah di akhir file. D) Membaca isi file. Show Answer Correct Answer: D) Membaca isi file. 8. In what scenarios would you use the Dump function in Python? A) CSV formatted string. B) Binary file. C) In scenarios where you need to convert a Python object into a string. D) XML formatted string. Show Answer Correct Answer: C) In scenarios where you need to convert a Python object into a string. 9. What is the best way to read an entire file into a list of strings? A) .read(). B) .readline(). C) .readlines(). D) .read(all). Show Answer Correct Answer: C) .readlines(). 10. How do you CALL the function name in Python? A) Name(). B) Def name(). C) Call name(). D) GOTO name(). Show Answer Correct Answer: A) Name(). 11. What does the "t" mode specify when opening a file in Python? A) Transfer mode. B) Text mode. C) Truncate mode. D) Temporary file. Show Answer Correct Answer: B) Text mode. 12. How does the OCR Exam Reference Language handle file opening compared to Python? A) Uses different parameters for file modes. B) Does not require specifying the file mode. C) Only allows reading from files. D) Only allows writing to files. Show Answer Correct Answer: B) Does not require specifying the file mode. 13. Which method is used to write a string to a file in Python? A) Seek(). B) Read(). C) Readline(). D) Write(). Show Answer Correct Answer: D) Write(). 14. What does rewind() do? A) Resets the file position to the beginning. B) Checks for end of file. C) Closes an open file. D) Opens a file. Show Answer Correct Answer: A) Resets the file position to the beginning. 15. What is the purpose of the getc() function in C? A) Write a character to a file. B) Write a line to a file. C) Read a character from a file. D) Read a line from a file. Show Answer Correct Answer: C) Read a character from a file. 16. Explain the concept of thrashing in virtual memory. A) Thrashing refers to the process of compressing data in memory storage. B) Thrashing is a condition in virtual memory systems where excessive paging operations degrade system performance. C) Thrashing occurs when a system runs out of physical memory entirely. D) Thrashing is a method to optimize memory allocation in virtual systems. Show Answer Correct Answer: B) Thrashing is a condition in virtual memory systems where excessive paging operations degrade system performance. 17. To read the remaining line of the file from a file object called F ..... H, we use A) F H.read.remaining(). B) F H.read(remaining). C) F H.readlines(). D) F H.readline(). Show Answer Correct Answer: C) F H.readlines(). 18. Explain the concept of appending to a file in Python. A) Create a new file instead of appending to an existing one. B) Append data by using the 'w' flag when opening the file. C) Use the 'r' flag when opening the file to append data. D) Open the file in 'append' mode using the 'a' flag and write data to the file to add content without overwriting. Show Answer Correct Answer: D) Open the file in 'append' mode using the 'a' flag and write data to the file to add content without overwriting. 19. Which of these will raise an error if file already exists? A) 'a'. B) 'w'. C) 'x'. D) 'r'. Show Answer Correct Answer: C) 'x'. 20. File can be added to. File is created if it doesn't already exist. A) Read. B) Append. C) Write. D) None of the above. Show Answer Correct Answer: B) Append. 21. What is the significance of the 'encoding' parameter in file handling? A) The 'encoding' parameter specifies the file size limit. B) The 'encoding' parameter is used to set file permissions. C) The 'encoding' parameter is significant as it determines how text data is encoded and decoded during file operations. D) The 'encoding' parameter determines the file format type. Show Answer Correct Answer: C) The 'encoding' parameter is significant as it determines how text data is encoded and decoded during file operations. 22. In the pseudocode provided, what is the function used to open a file? A) Close(). B) Open(). C) Read(). D) Write(). Show Answer Correct Answer: B) Open(). 23. This method returns the number of characters written to the file. A) Write(). B) Type(). C) Print(). D) None of the above. Show Answer Correct Answer: A) Write(). 24. The content of a file "sample.txt" are shown below:1, 2, 3, 4'a', 'b', 'c'5, 23, 'me', 'peace" to', 'be', 'or' 'not' A) It can not be treated as CSV file as it is a text file. B) It can not be treated as CSV file as it contains mixed data. C) It can not be treated as CSV file as it contains different number of elements in different lines. D) It can be treated as a csv file. Show Answer Correct Answer: D) It can be treated as a csv file. 25. What is the code to open a file named as Old ..... Data for writing data to it? A) Open("My Data.dat", ). B) Open("My Data.dat", ios $ $ out). C) Open("My Data.dat", ios::out). D) Open("My Data.dat", ios out). Show Answer Correct Answer: C) Open("My Data.dat", ios::out). 26. Which method checks if a file is closed? A) File.closed. B) File.status(). C) File.terminated(). D) File.check(). Show Answer Correct Answer: A) File.closed. 27. What does seek(5) do in a file? A) Finds line 5. B) Reads 5 bytes. C) Moves pointer to 5th byte. D) Skips 5 characters. Show Answer Correct Answer: C) Moves pointer to 5th byte. 28. How can you read a CSV file using Python's built-in libraries? A) Use the 'csv' module to read a CSV file. B) Use the 'pandas' library to read a CSV file. C) Utilize the 'xml' module to parse a CSV file. D) Read a CSV file using the 'json' module. Show Answer Correct Answer: A) Use the 'csv' module to read a CSV file. 29. What will file.read(4) do? A) Read 4 characters. B) Read 4 lines. C) Read 4 bytes. D) A and c. Show Answer Correct Answer: D) A and c. 30. Function to read the entire file A) Read(2). B) Readlines(). C) Readline(). D) All of the above. Show Answer Correct Answer: B) Readlines(). 31. To read the entire contents of the file as a string from a file object fobj, the command should be: A) Fobj.read(2). B) Fobj.read(). C) Fobj.readlines(). D) Fobj.readline(). Show Answer Correct Answer: B) Fobj.read(). 32. What will happen when you run this code:with open('data.txt', 'r') as file:print(file.read())? A) It will show 'data.txt'. B) It will print the text inside 'data.txt'. C) The file will close after reading. D) An error message will appear. Show Answer Correct Answer: B) It will print the text inside 'data.txt'. 33. Which of these class contains the methods print() & println()? A) System. B) PrintStream. C) BUfferedOutputStream. D) System.out. Show Answer Correct Answer: C) BUfferedOutputStream. 34. What is missing from this code?file = open ( "test1 ..... ", "w" ) A) Mp3. B) Mov. C) Txt. D) Jpeg. Show Answer Correct Answer: C) Txt. 35. If break statement is inside a nested loop, break will terminate the innermost loop. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 36. Class Main { public static void main(String args[]) { try { throw 10; } catch(int e) { System.out.println("Got the Exception '' + e); } }} A) Got the Exception 10. B) Got the Exception 0. C) Compiler Error. D) None. Show Answer Correct Answer: C) Compiler Error. 37. Assume that the customer file references a file object, and the file was opened using the 'w' mode specifier. How would you write the string 'Mary Smith' to the file? A) Customer.input('Mary Smith'). B) Customer file.write('Mary Smith'). C) Customer.write('Mary Smith'). D) Customer.write('w', 'Mary Smith'). Show Answer Correct Answer: C) Customer.write('Mary Smith'). 38. Every file maintains a ..... which tells the current position in the file. A) File pointer. B) Cursor. C) Paths. D) Bytes. Show Answer Correct Answer: A) File pointer. 39. Which mode should be used with pickle.load()? A) 'rb'. B) 'wb'. C) 'r'. D) 'w'. Show Answer Correct Answer: A) 'rb'. 40. What does the "t" in the mode "rt" stand for when opening a file in Python? A) Transfer. B) Tab-delimited. C) Temporary. D) Text. Show Answer Correct Answer: D) Text. 41. What is the purpose of a pointer FILE* in C? A) To store the position in memory of the beginning of a file. B) To define the type of file access. C) To create a new file. D) To close an open file. Show Answer Correct Answer: A) To store the position in memory of the beginning of a file. 42. To create the reader object, the correct syntax is ..... [Assume that the salesdet.csv file is opened in reading mode in the file handle fh. A) Salesdet reader=csvreader(fh). B) Salesdet reader=csv.read(fh). C) Salesdet reader=csvreader.fh. D) Salesdet reader=csv.reader(fh). Show Answer Correct Answer: D) Salesdet reader=csv.reader(fh). 43. What does the pathlib module do? A) Handles file paths automatically. B) Creates files. C) Deletes files. D) Changes file extensions. Show Answer Correct Answer: A) Handles file paths automatically. 44. What are file extensions? A) The size of the file. B) The part after the dot in a filename. C) The location of the file. D) The type of the operating system. Show Answer Correct Answer: B) The part after the dot in a filename. 45. What does the 'seekg' function do in file handling? A) It opens a file for writing. B) It reads data from the file. C) It closes the file. D) It moves the read position to a specified location. Show Answer Correct Answer: D) It moves the read position to a specified location. 46. What is the function of the mode ' w+'? A) Create text file for update, do not discard previous contents if any. B) Create text file for writing, discard previous contents if any. C) Create text file for update, discard previous contents if any. D) Create text file for writing, do not discard previous contents if any. Show Answer Correct Answer: C) Create text file for update, discard previous contents if any. 47. Which mode in Python is used to open a file for writing? A) A. B) W. C) R. D) X. Show Answer Correct Answer: B) W. 48. CSV module allows writing multiple records in a CSV file using A) Writelines. B) Writerows(). C) Writerec(). D) Writerow(). Show Answer Correct Answer: B) Writerows(). 49. Which statement correctly opens a file for exclusive creation? A) F = open('file.txt', 'w'). B) F = open('file.txt', 'r'). C) F = open('file.txt', 'x'). D) F = open('file.txt', 'a'). Show Answer Correct Answer: C) F = open('file.txt', 'x'). 50. Given a text file opened as file ..... in, which of the following will print the entire file? A) Print(file in.get()). B) Print(file in.readline()). C) For line in file in:print(line). D) Print(file in.read()). Show Answer Correct Answer: D) Print(file in.read()). 51. When you open a file for reading and if the file does not exist what occurs? A) New file will be created. B) An error occurs. C) Both a and d. D) The program will open a empty file. Show Answer Correct Answer: D) The program will open a empty file. 52. What is the purpose of debugging? A) To find and fix errors in the code. B) To write new code. C) To optimize the code. D) To document the code. Show Answer Correct Answer: A) To find and fix errors in the code. 53. The command file.closed returns: A) True or False. B) Error. C) File size. D) File name. Show Answer Correct Answer: A) True or False. 54. What happens if you try to read past the end of a file? A) It loops indefinitely. B) It sets the eof flag. C) It returns an error code. D) The program crashes. Show Answer Correct Answer: B) It sets the eof flag. 55. A class which is used for reading information from data files is called A) Ifstream. B) Iostream. C) Ofstream. D) Fstream. Show Answer Correct Answer: A) Ifstream. 56. Python deals with ..... different types of a file. A) Four. B) Three. C) Five. D) Two. Show Answer Correct Answer: B) Three. 57. What is the purpose of the 'shelve' module? A) To read text files. B) To create temporary files. C) To manage file paths. D) To save variables in a binary format. Show Answer Correct Answer: D) To save variables in a binary format. 58. What does the program that checks for end of file do? A) Writes data to the file. B) Prints the contents of the file until EOF. C) Checks for file errors. D) Opens a file. Show Answer Correct Answer: B) Prints the contents of the file until EOF. 59. The best mode to store a structure is: A) Binary mode. B) Console mode. C) Text mode. D) Append mode. Show Answer Correct Answer: A) Binary mode. 60. When a program reads a file, it enters every character into memory as a tuple A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: B) FALSE. ← PreviousNext →Related QuizzesScience QuizzesClass 11 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 8 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books