This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 11 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 11 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What is the file extension for CSV files? A) .data. B) .bin. C) .csv. D) .txt. Show Answer Correct Answer: C) .csv. 2. ..... is a location to store permanently (Secondary)in a system for future use A) Folder. B) Information. C) File. D) Data. Show Answer Correct Answer: C) File. 3. Yashi wants to check whether her name is listed in Shortlisted.dat or not. Which command she can write to open the file: A) A=open( "Shortlisted.dat" , "rb" ). B) With open ( "Shortlisted.dat', 'rb" ) as a:. C) None. D) Both a and b. Show Answer Correct Answer: D) Both a and b. 4. What function is used to read a text file in Python? A) FetchFile(). B) LoadText(). C) Open(). D) ReadFile(). Show Answer Correct Answer: C) Open(). 5. Which of the following represents mode of both writing and reading in binary format in file? A) W. B) Wb. C) W+. D) Wb+. Show Answer Correct Answer: D) Wb+. 6. True or False:One way you could use a csv file is to add new units/floorplans to a building A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 7. Which section in the content includes "Random accessing files" ? A) Writing into a file. B) File handling in C. C) Special streams in C. D) Random accessing files. Show Answer Correct Answer: D) Random accessing files. 8. In seek()-mode 0 will indicate. A) Current Position of File. B) Pointer Value. C) BOF. D) EOF. Show Answer Correct Answer: C) BOF. 9. What is the process of reading data from a text file called? A) Data extraction. B) File reading. C) File parsing. D) Text scanning. Show Answer Correct Answer: B) File reading. 10. What type of data does read() return? A) List. B) String. C) Float. D) Integer. Show Answer Correct Answer: B) String. 11. Which of the following prints contents of a file line by line? A) With open("test.txt") as ffor line in f:print(line, end=" ). B) With open("test.txt") as f:f.read(). C) With open("test.txt ", 'w') as f:for line in f:print(line, end=" ). D) With open("test.txt ", 'r') as f for line in f print(line, end=" ). Show Answer Correct Answer: A) With open("test.txt") as ffor line in f:print(line, end=" ). 12. What will happen if you try to open an existing file in 'x' mode? A) It will overwrite the file. B) It will raise an error. C) It will create a new file. D) It will open the file for reading. Show Answer Correct Answer: B) It will raise an error. 13. The type of file doesn't require translation or specific encoding A) Binary. B) Text. C) CSV. D) All of the above. Show Answer Correct Answer: A) Binary. 14. When you try to open a non existing file then A) New file will be created in the given name. B) Question should i open new file in given name popped. C) Error. D) Statement file not available. Show Answer Correct Answer: A) New file will be created in the given name. 15. Provide an example of an Absolute Path in file handling. A) /home/user/documents/file.txt. B) /documents/file.txt. C) /root/user/documents/file.txt. D) C:/user/documents/file.txt. Show Answer Correct Answer: D) C:/user/documents/file.txt. 16. What does the following code do?f = open('file.txt', 'r')lines = f.readlines()f.close() A) Reads the entire file and prints it. B) Reads the entire file into a list of lines. C) Reads the first line of the file. D) Reads the file in binary mode. Show Answer Correct Answer: B) Reads the entire file into a list of lines. 17. What does the readfile() function do in PHP? A) Writes content to a file. B) Reads a file and writes it to the output buffer. C) Creates a new file. D) Delete a file. Show Answer Correct Answer: B) Reads a file and writes it to the output buffer. 18. Which type of file stores data in binary format? A) CSV file. B) Binary file. C) JSON file. D) Text file. Show Answer Correct Answer: B) Binary file. 19. What is the topic that we discussed? A) File Sorting. B) File Organization. C) File Handling and Applications. D) File Editing. Show Answer Correct Answer: C) File Handling and Applications. 20. What happens if no arguments are passed to the seek () method? A) File position is set to the start of file. B) File position is set to the end of file. C) File position remains unchanged. D) Results in an error. Show Answer Correct Answer: C) File position remains unchanged. 21. What is the purpose of closing a file after using it? A) To free up system resources and ensure data is saved correctly. B) To clear all file contents. C) To improve program execution speed. D) To lock the file from other users. Show Answer Correct Answer: A) To free up system resources and ensure data is saved correctly. 22. What happens if you try to read from a file that does not exist? A) The program reads null values from the file. B) The program throws an error indicating the file cannot be found. C) The program automatically creates a backup of the file. D) The program creates a new empty file and reads from it. Show Answer Correct Answer: B) The program throws an error indicating the file cannot be found. 23. How can a program read an entire line from a text file? A) Use a command like file.readLine() (or similar based on the language). B) Read each character separately using a loop. C) Convert the file into an array before reading. D) Open the file in write mode first. Show Answer Correct Answer: A) Use a command like file.readLine() (or similar based on the language). 24. What does the os.path.basename() function return? A) The file name. B) The directory name. C) The file size. D) The full path. Show Answer Correct Answer: A) The file name. 25. The readlines() returns A) Only first line from the file. B) Only last line from the file. C) All lines from the file. D) None of the above. Show Answer Correct Answer: C) All lines from the file. 26. A pre-defined function is known as A) User defined function. B) Builtin function. C) Programming function. D) Constructed function. Show Answer Correct Answer: B) Builtin function. 27. This method returns a list where the text between the specified separator becomes the list items. A) Upper(). B) Split(). C) Lower(). D) Replace(). Show Answer Correct Answer: B) Split(). 28. Which of the following is NOT a function mentioned in the literacy section? A) Delete. B) Write. C) Close. D) Read. Show Answer Correct Answer: A) Delete. 29. What is the significance of the 'Boolean variable' in the Python file handling examples? A) It indicates the file size. B) It indicates the file type. C) It indicates the end of the file. D) It indicates the file name. Show Answer Correct Answer: C) It indicates the end of the file. 30. What does the csv.writerow() function do? A) Appends a row to a csv file. B) Writes a single row to a csv file. C) Deletes a row from a csv file. D) Reads a single row from a csv file. Show Answer Correct Answer: B) Writes a single row to a csv file. 31. What is the file mode 'r' in Python A) Read Mode. B) Write Mode. C) Append Mode. D) None of the above. Show Answer Correct Answer: A) Read Mode. 32. What will file.read() return? A) Nothing. B) One character. C) The entire file content as a string. D) A list of lines. Show Answer Correct Answer: C) The entire file content as a string. 33. What happens if a file opened with 'ofstream' already exists? A) The file is appended. B) A new file is created with a different name. C) The file is deleted. D) The file is overwritten. Show Answer Correct Answer: D) The file is overwritten. 34. What are the two valid keywords used for an exception? A) Try:catch:. B) Try:except:. C) Try:iferror:. D) Run:iferror:. Show Answer Correct Answer: B) Try:except:. 35. 5 'try' block is used to A) Execute a code. B) Through the exceptions. C) To try some random code. D) To give errors. Show Answer Correct Answer: B) Through the exceptions. 36. In f=open("fun.txt", 'r'), 'r' refers to ..... A) File name. B) File object. C) File pointer. D) File mode. Show Answer Correct Answer: D) File mode. 37. How do you create a new directory in Python? A) Make directory('new directory name'). B) Os.mkdir('new directory name'). C) Os.create('new directory name'). D) Create directory('new directory name'). Show Answer Correct Answer: B) Os.mkdir('new directory name'). 38. A variable defined inside the def() we called as A) Local to def(). B) Global. C) Local. D) Enclosing. Show Answer Correct Answer: A) Local to def(). 39. What is the output of the following code?def greet(name="Guest"):print(f"Hello, {name}!")greet("Alice")greet() A) Error due to missing argument. B) Hello, Alice! Hello, Guest!. C) Hello, Guest! Hello, Alice!. D) Hello, Guest! Hello, Guest!. Show Answer Correct Answer: C) Hello, Guest! Hello, Alice!. 40. What is the purpose of saving data to a file in a program? A) To increase the speed of the program. B) To store data temporarily in memory. C) To ensure data persists after the program has finished. D) To make the data disappear after the program ends. Show Answer Correct Answer: C) To ensure data persists after the program has finished. 41. What is the output of:x = ["apple", "banana"]print("banana" in x) A) 2. B) 1. C) True. D) False. Show Answer Correct Answer: C) True. 42. Address stored in the pointer variable is of type. A) Declared. B) Initialized. C) Both declared and initialized. D) Not both declared and initialized. Show Answer Correct Answer: C) Both declared and initialized. 43. The ..... enables you to write or read data in a position wherever you want. A) Random Access. B) Read Only. C) All the above. D) None of the above. Show Answer Correct Answer: A) Random Access. 44. What is the role of the 'pickle' module in data serialization? A) The 'pickle' module is used for data visualization in Python. B) The 'pickle' module encrypts data for secure storage. C) The 'pickle' module is a database management tool for Python. D) The 'pickle' module facilitates data serialization by converting Python objects to byte streams and vice versa. Show Answer Correct Answer: D) The 'pickle' module facilitates data serialization by converting Python objects to byte streams and vice versa. 45. How can you read a binary file in Python? A) Use open('filename', 'wb') to read a binary file in Python. B) Use open('filename', 'rb') to read a binary file in Python. C) Read the file using open('filename', 'text') for binary data. D) Use open('filename', 'r') to read a binary file in Python. Show Answer Correct Answer: B) Use open('filename', 'rb') to read a binary file in Python. 46. What does the 'os.path.split()' function return? A) The directory name and base name as a tuple. B) The size of the file. C) The file extension. D) The absolute path of the file. Show Answer Correct Answer: A) The directory name and base name as a tuple. 47. ..... function without any argument removes leading and trailing whitespaces. A) Lstrip(). B) Trim(). C) Strip(). D) Rstrip(). Show Answer Correct Answer: C) Strip(). 48. Explain the difference between reading a file in text mode and binary mode. A) Text mode compresses file size, while binary mode decompresses it. B) Text mode interprets file content as human-readable text, while binary mode reads raw bytes without decoding. C) Text mode converts all characters to uppercase, while binary mode keeps the original case. D) Text mode reads files in reverse order, while binary mode reads them sequentially. Show Answer Correct Answer: B) Text mode interprets file content as human-readable text, while binary mode reads raw bytes without decoding. 49. Which function is used to write data in binary file? A) Pickle.put(). B) Pickle.write(). C) Pickle.dump(). D) Pickle.save(). Show Answer Correct Answer: C) Pickle.dump(). 50. In a file, user want to add and write the data means, he want to open the file in ..... , , , mode A) A+. B) W+. C) R+. D) All these. Show Answer Correct Answer: A) A+. 51. What is the purpose of using Fileoutputstream in Java? A) To create a new file. B) To delete a file. C) To write data to a file. D) To read data from a file. Show Answer Correct Answer: C) To write data to a file. 52. What is the purpose of the 'csv.writer' object? A) To write data to a CSV file. B) To read data from a CSV file. C) To display CSV data in a graphical interface. D) To convert CSV data into JSON format. Show Answer Correct Answer: A) To write data to a CSV file. 53. If there is any error while opening a file, fopen will return? A) NULL. B) Depends on compiler. C) EOF. D) Nothing. Show Answer Correct Answer: A) NULL. 54. What happens when you try to open a file that does not exist using the code?with open("test.txt", 'w') as f: A) A new file is created. B) Error message pops up. C) Nothing happens. D) None of the above. Show Answer Correct Answer: A) A new file is created. 55. Choose the correct statement to close a file stream named myfile: A) Myfile.terminate(). B) Myfile.close(). C) Myfile.remove(). D) Myfile.end(). Show Answer Correct Answer: B) Myfile.close(). 56. Apa yang dimaksud dengan operasi "menambahkan data" ke file? A) Menulis data baru di awal file. B) Menghapus data yang ada. C) Menulis data baru di akhir file. D) Membaca data dari file. Show Answer Correct Answer: C) Menulis data baru di akhir file. 57. You must write pickle.load() enclosed in ..... and ..... statements. A) Dunp & Load. B) Try & Except. C) Pickle & Unpickle. D) Try & Catch. Show Answer Correct Answer: B) Try & Except. 58. What is the correct syntax to close a file in the pseudocode provided? A) Myfile.read(). B) Myfile.open(). C) Myfile.write(). D) Myfile.close(). Show Answer Correct Answer: D) Myfile.close(). 59. How do you open a CSV file in Python? A) Open('file.csv'). B) Pandas.read csv('file.csv'). C) Csv.load('file.csv'). D) Import csvwith open('file.csv', mode='r') as file:reader = csv.reader(file) for row in reader:print(row). Show Answer Correct Answer: D) Import csvwith open('file.csv', mode='r') as file:reader = csv.reader(file) for row in reader:print(row). 60. Which mode opens a file for reading and writing in Python? A) "a+". B) "w". C) "r". D) "r+". Show Answer Correct Answer: D) "r+". ← 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