This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 18 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 18 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Apa tipe data yang akan dikembalikan oleh fungsi pandas.read ..... csv()? A) DataFrame. B) String. C) Ndarray. D) Dictionary. Show Answer Correct Answer: A) DataFrame. 2. The ..... mode adds the data to the end of file. A) Write. B) Append. C) Read. D) Both write and append. Show Answer Correct Answer: B) Append. 3. Tell( ) function use to see the current position of the file pointer. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 4. Which mode specifier will open a file but will not let you change the file or write to it? A) 'w'. B) 'E'. C) 'r'. D) 'a'. Show Answer Correct Answer: C) 'r'. 5. What are the basic file operations in Python? A) The basic file operations in Python are:open, read, write, and close. B) Open, save, import, export. C) Read, write, append, sync. D) Create, delete, modify, execute. Show Answer Correct Answer: A) The basic file operations in Python are:open, read, write, and close. 6. To perform File I/O operations, Which of the following header files is used? A) . B) . C) Any of these. D) . Show Answer Correct Answer: A) . 7. What does this code do?file.write ( song ) A) It writes the word "song" to the file. B) It reads the word "song" from the file. C) It reads the variable "song" from the file. D) It writes the variable "song" to the file. Show Answer Correct Answer: D) It writes the variable "song" to the file. 8. Exception generated by try block is caught in ..... block? A) Catch. B) Throw. C) Throws. D) Finally. Show Answer Correct Answer: B) Throw. 9. File handling commands vary from language to language A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: A) TRUE. 10. Which method reads only a single line from the file? A) Readline(). B) Line(). C) Readlines(). D) Read(). Show Answer Correct Answer: A) Readline(). 11. When we want to read from or write to a file, we need to open it first. When we are done, it needs to be closed, so that resources that are tied with the file are freed. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 12. What will happen if we forget to close a file? A) File gets deleted. B) File cannot be accessed again. C) May not save data. D) Nothing. Show Answer Correct Answer: C) May not save data. 13. Making some changes in the data of the existing file or adding more data is called A) Alteration. B) Editing. C) Appending. D) Modification. Show Answer Correct Answer: D) Modification. 14. Which method is used to break the link of file object and the file on the disk. A) End. B) Break. C) Open. D) Close. Show Answer Correct Answer: D) Close. 15. What does the 'read' method do when used on a file? A) It writes data to the file. B) It gets all data from the file. C) It deletes the file. D) It creates a new file. Show Answer Correct Answer: B) It gets all data from the file. 16. Which of the following is correct for reading the entire contents of a file as a string? A) File.read(). B) File.readlines(). C) File.readchars(). D) File.readline(). Show Answer Correct Answer: A) File.read(). 17. What method would you use to write data to a file? A) Open the file in append mode only. B) Use file writing methods such as 'write()' or 'writelines()' after opening the file in write mode. C) Use 'read()' to access file data. D) Use 'delete()' to remove file contents. Show Answer Correct Answer: B) Use file writing methods such as 'write()' or 'writelines()' after opening the file in write mode. 18. What does the fwrite() function do in PHP? A) Reads data from a file. B) Opens a file for reading. C) Writes data to a file. D) Closes a file. Show Answer Correct Answer: C) Writes data to a file. 19. Select a function which is used to write a string to a file A) Fputs(). B) Fgets(). C) Putc(). D) Pits(). Show Answer Correct Answer: A) Fputs(). 20. Java uses the concept of A) Source. B) Stream. C) Section. D) Standard. Show Answer Correct Answer: B) Stream. 21. How does the Pickle Module help in storing Python objects? A) The Pickle Module converts Python objects into JSON format for storage. B) The Pickle Module compresses Python objects into smaller files for storage. C) The Pickle Module encrypts Python objects for secure storage. D) The Pickle Module serializes Python objects into byte streams for storage and retrieval. Show Answer Correct Answer: D) The Pickle Module serializes Python objects into byte streams for storage and retrieval. 22. What is the purpose of the 'close' function in file handling? A) To delete the file. B) To open a new file. C) To read data from the file. D) To save changes and release resources. Show Answer Correct Answer: D) To save changes and release resources. 23. M=open("rt.dat", "wb+")Here, the above coed, b will indicate ..... A) Binary Mode. B) Byte. C) Write mode. D) Read Mode. Show Answer Correct Answer: A) Binary Mode. 24. What method would you use to write data to a text file? A) Utilize the 'writefile' method directly on the file object. B) Use the 'open' function with 'write' mode and the 'write' method. C) Open the file in 'read' mode and modify its contents. D) Use the 'append' function with 'read' mode. Show Answer Correct Answer: B) Use the 'open' function with 'write' mode and the 'write' method. 25. When the pointer variable is declared, the variable name must be preceded by which symbol? A) $\rightarrow$. B) &. C) . D) *. Show Answer Correct Answer: D) *. 26. How can you write a string to a file in Python? A) Open('filename.txt', 'w').write('Your string here'). B) Write('Your string here', 'filename.txt'). C) Open('filename.txt', 'a').write('Your string here'). D) Open('filename.txt', 'r').write('Your string here'). Show Answer Correct Answer: A) Open('filename.txt', 'w').write('Your string here'). 27. The void pointer can point to which type of objects? A) Int. B) Float. C) Double. D) All of the above. Show Answer Correct Answer: D) All of the above. 28. What is missing form this code?file = open ( "test1.txt" , " ..... " ) A) Wrt. B) W. C) Written. D) Write. Show Answer Correct Answer: B) W. 29. Explain the concept of data serialization. A) Data serialization is a method of creating backups of data in cloud storage. B) Data serialization refers to the physical storage of data on hard drives. C) Data serialization allows for the efficient storage and transmission of data by converting it into a standardized format. D) Data serialization is the process of encrypting data for security purposes. Show Answer Correct Answer: C) Data serialization allows for the efficient storage and transmission of data by converting it into a standardized format. 30. Which of the following key word is optional in Exception handling program A) Try. B) Catch. C) Finally. D) Throw. Show Answer Correct Answer: C) Finally. 31. Explain the difference between 'rb' and 'wb' modes. A) 'rb' is for writing text files, while 'wb' is for reading text files. B) Both 'rb' and 'wb' are used for reading files only. C) 'rb' is for reading files in a compressed format, while 'wb' is for writing in plain text. D) The difference between 'rb' and 'wb' modes is that 'rb' is for reading binary files, while 'wb' is for writing binary files. Show Answer Correct Answer: D) The difference between 'rb' and 'wb' modes is that 'rb' is for reading binary files, while 'wb' is for writing binary files. 32. What about today's Class? A) Good. B) Average. C) Bad. D) None of the above. Show Answer Correct Answer: A) Good. 33. Sarah wants to add her journal entry at the bottom of journal.txt without losing previous entries. Which mode should she use? A) "w". B) "r+". C) "a". D) "r". Show Answer Correct Answer: C) "a". 34. What is the advantage of Exception Handling A) To avoid abnormal termination of a program. B) To find out errors. C) To Debug program. D) None of these. Show Answer Correct Answer: A) To avoid abnormal termination of a program. 35. What is the purpose of the 'dot strip' method in Python file handling? A) To remove spaces from the text file. B) To remove new line characters from the text file. C) To remove special characters from the text file. D) To remove punctuation from the text file. Show Answer Correct Answer: B) To remove new line characters from the text file. 36. Text file student.txt is stored in the storage device. Identify the correct option out of the following options to open the file in read mode. A) Myfile = open('student.txt', 'w'). B) Myfile = open('student.txt'). C) Myfile = open('student.txt', 'rb'). D) Myfile = open('student.txt', 'r'). Show Answer Correct Answer: D) Myfile = open('student.txt', 'r'). 37. We cannot use text files to store images as the images do not contain characters. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 38. Rewind takes a file pointer and resets position to the A) Start of the file. B) End of the file. C) Desired location of the file. D) All of the above. Show Answer Correct Answer: A) Start of the file. 39. Why is it important to close a file after performing operations on it? A) To release system resources, ensure data integrity, and prevent memory leaks. B) To introduce bugs in the code. C) To confuse other developers. D) To increase system performance. Show Answer Correct Answer: A) To release system resources, ensure data integrity, and prevent memory leaks. 40. To perform file processing in C++, header files and must be included in your C++ source file. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 41. Which function opens a file in C? A) Startfile(). B) File open(). C) Fopen(). D) Openfile(). Show Answer Correct Answer: C) Fopen(). 42. Which function is used to read the entire content of a file? A) File.readline(). B) File.readlines(). C) File.write(). D) File.read(). Show Answer Correct Answer: D) File.read(). 43. In PHP you can use both single quotes ( ' ' ) and double quotes ( '' '' ) for strings: A) True. B) False. C) Both. D) None. Show Answer Correct Answer: C) Both. 44. !feof stands for A) File end of file. B) Not file end of file. C) Exlamatory file end of file. D) None. Show Answer Correct Answer: A) File end of file. 45. What is the mode 'r' used for when opening a file? A) Binary mode. B) Append mode. C) Write-only mode. D) Read-only mode. Show Answer Correct Answer: D) Read-only mode. 46. Which of the following modes is used to open a file in binary mode? A) 'ios::out'. B) 'ios::app'. C) 'ios::trunc'. D) 'ios::binary'. Show Answer Correct Answer: D) 'ios::binary'. 47. Where can the 'continue' statement be used in C++? A) Inside functions. B) Only inside switch statements. C) Inside loops and switch statements. D) Only inside loops. Show Answer Correct Answer: D) Only inside loops. 48. Which of these is a list? A) ("apples", "oranges", "bananas"). B) {"apples", "oranges", "bananas"}. C) ["apples", "oranges", "bananas"]. D) "apples", "oranges", "bananas". Show Answer Correct Answer: C) ["apples", "oranges", "bananas"]. 49. Which statement is used to retrieve the current position within the file? A) Fp.seek(). B) Fp.loc. C) Fp.tell(). D) Fp.pos. Show Answer Correct Answer: C) Fp.tell(). 50. What is the syntax to write to a file in Python? A) Write.file(content). B) File.write(content). C) Content.write(file). D) File.write(content). Show Answer Correct Answer: B) File.write(content). 51. Value erroe occur due to wrong indentation in a program A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 52. What does the anchor attribute of a Path object represent? A) The root folder of the filesystem. B) The name of the file. C) All the above. D) None of the above. Show Answer Correct Answer: A) The root folder of the filesystem. 53. What is the name of the file used in the example? A) Text.txt. B) Data.txt. C) Example.txt. D) File.txt. Show Answer Correct Answer: B) Data.txt. 54. If we want to customize our response to the error type that occurs, which could we use? A) Except:. B) Except ErrorType:. C) All the above. D) None of the above. Show Answer Correct Answer: B) Except ErrorType:. 55. Which method is used to test if a file is readable? A) Readable(). B) CanRead(). C) Read(). D) IsReadable(). Show Answer Correct Answer: B) CanRead(). 56. To read 18 characters from the file object fobj, the correct syntax is ..... A) Fobj.readline(18). B) Fobj.readchar(18). C) Fobj.read(18). D) Fobj.readlines(18). Show Answer Correct Answer: C) Fobj.read(18). 57. 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(). 58. How do you read the entire content of a text file in Python? A) Content = open('filename.txt').read(). B) Content = open('filename.txt', 'r').read(). C) Content = readfile('filename.txt'). D) Content = read('filename.txt'). Show Answer Correct Answer: B) Content = open('filename.txt', 'r').read(). 59. Which of the follwing methods is used to write() into a file? A) Put(). B) Print(). C) WriteFile(). D) Write(). Show Answer Correct Answer: D) Write(). 60. What will be the output of the following snippet? A) True. B) False. C) None. D) Error. Show Answer Correct Answer: A) True. ← 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