This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 3 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 3 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What does the createNewFile() method return if the file is successfully created? A) Null. B) Void. C) False. D) True. Show Answer Correct Answer: D) True. 2. What is the purpose of the 'for loop' in Python file handling? A) To append to the end of the file. B) To read every line from a file one at a time. C) To write data to the file. D) To close the file. Show Answer Correct Answer: B) To read every line from a file one at a time. 3. What is serialization in the context of binary files? A) Converting a Python object to a byte stream. B) Converting a byte stream to a Python object. C) Reading data from a file. D) Writing text to a file. Show Answer Correct Answer: A) Converting a Python object to a byte stream. 4. Apa yang dilakukan fscanf? A) Membaca data terformat dari file. B) Menulis data terformat ke file. C) Membuka file. D) Menutup file. Show Answer Correct Answer: A) Membaca data terformat dari file. 5. Which of the following file types allows to store large data files in the computer memory? A) Text Files. B) Binary Files. C) CSV Files. D) None of these. Show Answer Correct Answer: B) Binary Files. 6. What is used to remove the newline character when reading from a file? A) .remove(). B) .delete(). C) .cut(). D) .strip(). Show Answer Correct Answer: D) .strip(). 7. What is the function of 'seek()' in file handling? A) The 'seek()' function reads data from the file. B) The 'seek()' function changes the current position of the file pointer. C) The 'seek()' function closes the file after use. D) The 'seek()' function writes data to the file. Show Answer Correct Answer: B) The 'seek()' function changes the current position of the file pointer. 8. If you will have to store marks of 10 students then which python datatype will you use? A) Set. B) Dictionary. C) List. D) String. Show Answer Correct Answer: B) Dictionary. 9. What is the purpose of 'fileP.write(str(i) + '' ")' in the loop? A) To append data to a file. B) To delete data from a file. C) To read data from a file. D) To write each prime number followed by a space to the file. Show Answer Correct Answer: D) To write each prime number followed by a space to the file. 10. Which class is used to write text to a file in Java? A) Scanner. B) FileReader. C) BufferedReader. D) FileWriter. Show Answer Correct Answer: D) FileWriter. 11. Which header file must be included to use file I/O operations in C++? A) . B) . C) . D) . Show Answer Correct Answer: A) . 12. Which of the following file types is typically a text file? A) .mp3. B) .txt. C) .exe. D) .jpg. Show Answer Correct Answer: B) .txt. 13. Which superglobal variable holds information about headers, paths, and script locations? A) $ GLOBALS. B) $ SERVER. C) $ SESSION. D) None. Show Answer Correct Answer: B) $ SERVER. 14. Which function is used to read the data from a binary file? A) Pickle.readlines(). B) Pickle.load(). C) Pickle.read(). D) Pickle.dump(). Show Answer Correct Answer: B) Pickle.load(). 15. How can you read binary data from a file? A) Use 'open(filename, 'rb')' to read binary data from a file. B) Employ 'load(filename, 'rb')' to retrieve binary content. C) Open the file with 'open(filename, 'text')' for binary read. D) Use 'read(filename, 'b')' to access binary data. Show Answer Correct Answer: A) Use 'open(filename, 'rb')' to read binary data from a file. 16. What is the parent class of All Exceptions in JAVA A) Bug. B) Exception. C) Error. D) Throw. Show Answer Correct Answer: D) Throw. 17. If a file exists, then it deletes the file content prior to its opening. A) Ios::app. B) Ios::in. C) Ios::ate. D) Ios::out. E) Ios::trunc. Show Answer Correct Answer: E) Ios::trunc. 18. How can you move the file pointer to the beginning of a file? A) Use the read method to access the file. B) Close the file and reopen it. C) Use the tell method to check the position. D) Use the seek method with an offset of 0. Show Answer Correct Answer: D) Use the seek method with an offset of 0. 19. What is the purpose of the 'flush()' method when working with files? A) It closes the file immediately. B) It reads the file contents into memory. C) It clears the file contents. D) It forces the write buffer to be flushed to the file. Show Answer Correct Answer: D) It forces the write buffer to be flushed to the file. 20. SequenceInputStream class is used to read data from ..... A) Multilevel Streams. B) Single Stream. C) Multiple streams. D) None of given. Show Answer Correct Answer: C) Multiple streams. 21. Which is an advantage of CSV over text file? A) Stores images directly. B) Faster than binary. C) Can store Python objects. D) Easier for tabular data exchange. Show Answer Correct Answer: D) Easier for tabular data exchange. 22. What will this line of code do?myFile = open("test ..... scores.txt", "w") A) Opens the text file 'test scores' in wait mode. B) Opens the text file 'test scores' in writing mode-appends new data to the end of the file. C) Opens the text file 'test scores' in reading mode. D) Opens the text file 'test scores' in writing mode-overwrites contents. Show Answer Correct Answer: D) Opens the text file 'test scores' in writing mode-overwrites contents. 23. Which of these class is not a member class of java.io package? A) String. B) FileWriter. C) File. D) FileReader. Show Answer Correct Answer: A) String. 24. Why should you avoid closing a file according to the document? A) To delete it. B) To rename it. C) To save changes. D) To keep it accessible. Show Answer Correct Answer: D) To keep it accessible. 25. Which option is correct about this program? f=open( "ss.txt" , "wb" ) print( "Name of the file:" , f.name) f.flush() f.close() A) Runtime error. B) No output. C) Compilation error. D) Flushes the file when closing them. Show Answer Correct Answer: D) Flushes the file when closing them. 26. Text file store information in ..... character A) ASCII. B) EOL. C) UNICODE. D) BOTH 1 & 3. Show Answer Correct Answer: A) ASCII. 27. Which of the following modes is used for both writing and reading from a binary file? A) W+. B) Wb. C) W. D) Wb+. Show Answer Correct Answer: D) Wb+. 28. Which function is used to open a file for reading in Python? A) Start. B) Read. C) Open. D) Load. Show Answer Correct Answer: C) Open. 29. What does this code do?file.write ( "Jumanji" ) A) It writes the name "Jumanji" to the file. B) It writes the name "Juman" to the file. C) It deletes the name "Jumanji" to the file. D) It deletes the name "Juman" to the file. Show Answer Correct Answer: A) It writes the name "Jumanji" to the file. 30. Those values are called as Default values: A) Defined in function Header. B) Defined in function. C) Defined in main. D) Defined in above def() statement. Show Answer Correct Answer: A) Defined in function Header. 31. What does the "r" mode do when opening a file in Python? A) Reads and writes to a file. B) Reads a file, creates a new file if it does not exist. C) Reads a file, error if the file does not exist. D) Reads a file, truncates the file first. Show Answer Correct Answer: C) Reads a file, error if the file does not exist. 32. Which statement will read 5 characters from a file(file object 'f')? A) F.read(). B) F.read(5). C) F.reads(5). D) None of the above. Show Answer Correct Answer: B) F.read(5). 33. How many parameters used to pass while opening a file? A) 0. B) 2. C) 1. D) 3. Show Answer Correct Answer: B) 2. 34. What is a 'file handle' in the context of opening a file? A) A tool to physically handle files. B) A special variable that points to the opened file. C) A password needed to access the file. D) The graphical icon of the file. Show Answer Correct Answer: B) A special variable that points to the opened file. 35. How do you write a list of strings to a file in Python? A) F.write(list of strings). B) With open('filename.txt', 'w') as f:f.writelines(" .join(list of strings)). C) Using print(list of strings). D) Open('filename.txt', 'r') as f:. Show Answer Correct Answer: B) With open('filename.txt', 'w') as f:f.writelines(" .join(list of strings)). 36. What happens to the cursor after 'readline()' is called? A) It moves to the beginning of the next line. B) It remains at the current position. C) It moves to the end of the line just read. D) It moves to the beginning of the file. Show Answer Correct Answer: A) It moves to the beginning of the next line. 37. How do you write to a file in append mode? A) Use open('filename.txt', 'x') to open a file in exclusive creation mode. B) Use open('filename.txt', 'a') to open a file in append mode. C) Use open('filename.txt', 'r') to open a file in read mode. D) Use open('filename.txt', 'w') to open a file in write mode. Show Answer Correct Answer: B) Use open('filename.txt', 'a') to open a file in append mode. 38. What does strip() function do? A) Removes the trailing or leading spaces, if any. B) Deletes the file. C) Remove the file object. D) Removes all the spaces between words. Show Answer Correct Answer: A) Removes the trailing or leading spaces, if any. 39. Given "myFile" is a file handle-what best describes what the following Python code does:for aLine in myFile:print(aLine) A) It writes the contents from the file handle myFile to the console. B) It reads each line from the file handle myFile, assigns it to a variable called aLine and prints to the console. C) It removes each line from the file handle myFile. D) It copies each line from the file handle myFile to a new file. Show Answer Correct Answer: B) It reads each line from the file handle myFile, assigns it to a variable called aLine and prints to the console. 40. What is a library in python? A) IT IS SUBPROGRAM. B) COLLECTION OF MODULES. C) NAME OF A FILE. D) COLLECTION OF FILES. Show Answer Correct Answer: B) COLLECTION OF MODULES. 41. What are the main differences between paging and segmentation? A) Paging is used for process management; segmentation is for file storage. B) Paging allows variable-sized pages; segmentation uses fixed-size segments. C) Paging uses fixed-size pages; segmentation uses variable-sized segments. D) Paging divides memory into segments; segmentation divides it into pages. Show Answer Correct Answer: C) Paging uses fixed-size pages; segmentation uses variable-sized segments. 42. What is data dependency? A) A type of data error. B) A method to write data. C) A requirement for data to be in a specific order. D) A Python library for file handling. Show Answer Correct Answer: C) A requirement for data to be in a specific order. 43. Which of the statement is not true regarding the opening mode of a file? A) When you open a file for writing, if the file does not exist, an error occurs. B) When you open a file for reading in r+ mode, if the file does not exist, an error occurs. C) When you open a file for reading, if the file does not exist, an error occurs. D) When you open a file for reading in w+ mode, if the file does not exist, a new file is created. Show Answer Correct Answer: A) When you open a file for writing, if the file does not exist, an error occurs. 44. What role does a cursor play in file handling? A) It manages the security of a file. B) It compresses the file data for storage efficiency. C) It encrypts the data being written to a file. D) It keeps track of the current location within the file when reading or writing. Show Answer Correct Answer: D) It keeps track of the current location within the file when reading or writing. 45. What is pickling? A) Pickling is a technique for compressing data files. B) Pickling is the serialization of a Python object into a byte stream. C) None of the mentioned. D) All of the mentioned. Show Answer Correct Answer: B) Pickling is the serialization of a Python object into a byte stream. 46. If a text file pointer is at the end after reading, which function resets it to the beginning? A) F.seek(0). B) F.flush(). C) F.restart(). D) F.reset(). Show Answer Correct Answer: A) F.seek(0). 47. What is the main focus of the practical implementation section? A) Writing programs. B) Reading files. C) Error handling. D) CSV files. Show Answer Correct Answer: A) Writing programs. 48. Overwrites existing data, starting from the beginning of the file. File is created if it doesn't already exist. A) Read. B) Append. C) Write. D) None of the above. Show Answer Correct Answer: C) Write. 49. Which of the statements is used to import all names from a module into the current calling module A) From. B) Import*. C) Dir(). D) Import. Show Answer Correct Answer: B) Import*. 50. Which of the following keyword not only belong to exception handling (It's under common keyword) A) Try. B) Except. C) Else. D) Finally. Show Answer Correct Answer: C) Else. 51. Apa yang dilakukan perror dalam program C? A) Menulis data ke file. B) Menutup file. C) Membuka file. D) Menampilkan pesan kesalahan. Show Answer Correct Answer: D) Menampilkan pesan kesalahan. 52. What are the different file modes in Python? A) C. B) R, w, a, x, t, b. C) R. D) W+. Show Answer Correct Answer: B) R, w, a, x, t, b. 53. Which symbols are used to open and close a list? A) ( ) round brackets. B) '' '' speech marks. C) ( ) curly brackets. D) [ ] square brackets. Show Answer Correct Answer: D) [ ] square brackets. 54. What method would you use to write multiple lines to a file at once? A) Use the 'append()' method. B) Use the 'writelines()' method. C) Use the 'write()' method. D) Use the 'flush()' method. Show Answer Correct Answer: B) Use the 'writelines()' method. 55. What is the purpose of the EOF character in a file? A) To indicate the start of the file. B) To point to the next file. C) To store metadata. D) To mark the end of the file. Show Answer Correct Answer: D) To mark the end of the file. 56. 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+. 57. What does the program that performs file position and seek operations do? A) Checks for end of file. B) Writes data to the file. C) Prints the character at position 5. D) Opens a file. Show Answer Correct Answer: C) Prints the character at position 5. 58. Choose the CORRECT exceptionString department="JTMK"; Integer no=Integer.parseInt(department); A) ArithmeticException. B) NumberFormatException. C) NullPointerException. D) ArrayIndexOutOfBoundsException. Show Answer Correct Answer: B) NumberFormatException. 59. 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. 60. 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. ← 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 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 9 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books