This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 12 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 12 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. F = open("test.txt", "a") f.write("Hello World!") A) It opens tht file in append mode which clears the previous text. B) It opens the file in write mode which adds text to the end of the file. C) It opens tht file in write mode which clears the previous text. D) It opens the file in append mode which adds text to the end of the file. Show Answer Correct Answer: D) It opens the file in append mode which adds text to the end of the file. 2. The ..... files are not in human readable form. A) Text file. B) Delimited text file. C) CSV File. D) Binary File. Show Answer Correct Answer: D) Binary File. 3. How do you read data from a file using Fileinputstream in Java? A) Create a FileInputStream object and use its read() method to read the data from the file. B) Open the file in a text editor and manually copy the data. C) Use a PrintWriter object to read the data from the file. D) Use a Scanner object to read the data from the file. Show Answer Correct Answer: A) Create a FileInputStream object and use its read() method to read the data from the file. 4. Each line in a CSV file is called a ..... A) Data Record. B) Modules. C) File. D) Record. Show Answer Correct Answer: A) Data Record. 5. How do you open a file for both reading and writing in C++? A) By using an 'fstream' object. B) By using an 'ifstream' object. C) By using an 'ofstream' object. D) By using an 'iostream' object. Show Answer Correct Answer: A) By using an 'fstream' object. 6. Which of the following modes should be used when opening a file for writing? A) "w" (write mode). B) "r" (read mode). C) "a" (append mode). D) "rw" (read and write mode). Show Answer Correct Answer: A) "w" (write mode). 7. The ..... text files which store the text in the same form as typed. A) CSV File. B) Delimited text file. C) Regular text file. D) Binary File. Show Answer Correct Answer: C) Regular text file. 8. Which statement is CORRECT about the 'READ' mode? A) It allows reading and writing. B) It allows only reading. C) It erases the file before reading. D) It adds new lines to the file. Show Answer Correct Answer: B) It allows only reading. 9. Apa nilai default dari parameter delimiter yang digunakan pada fungsi pandas.read ..... csv() dan numpy.loadtxt()? A) Koma (, ). B) Titik koma (;). C) Strip (-). D) Spasi ( ). Show Answer Correct Answer: A) Koma (, ). 10. Which of the following is a valid way to define a pointer to a structure? A) Ptr struct student;. B) Struct *ptr student;. C) Student *ptr struct;. D) Struct student *ptr;. Show Answer Correct Answer: D) Struct student *ptr;. 11. What happens if a program does not properly close a file after writing to it? A) Data may not be saved correctly. B) The file will be deleted automatically. C) The program will always crash immediately. D) The file's contents will be locked permanently. Show Answer Correct Answer: A) Data may not be saved correctly. 12. How can you pass a variable number of arguments to a function? A) Declare a fixed number of parameters in the function definition. B) Use **kwargs** to pass keyword arguments only. C) Use a list to pass multiple arguments as a single parameter. D) Use *args in Python to accept a variable number of arguments. Show Answer Correct Answer: D) Use *args in Python to accept a variable number of arguments. 13. Apa yang akan ditampilkan jika fgets berhasil membaca baris dari file? A) Pesan kesalahan. B) Konten baris yang dibaca. C) NULL. D) ID file. Show Answer Correct Answer: B) Konten baris yang dibaca. 14. What is the purpose of the with statement when working with files? A) To ensure that the file is closed properly after use. B) To open the file in read mode. C) To open the file in write mode. D) To manipulate the data in the file. Show Answer Correct Answer: A) To ensure that the file is closed properly after use. 15. This function connects the file written on the disk with file object A) Close(). B) Write(). C) Read(). D) Open(). Show Answer Correct Answer: D) Open(). 16. What is the code to open a file named as My ..... Data for reading data from it? A) Open("My Data.dat", ios::in). B) Open(My Data.dat, "ios::in"). C) Open(My Data.dat, ios::in). D) Open("My Data.dat", "ios::in"). Show Answer Correct Answer: A) Open("My Data.dat", ios::in). 17. The file pointer is reset to the start of the file using: A) Rewind(). B) Seek(0). C) Goto(0). D) Reset(). Show Answer Correct Answer: B) Seek(0). 18. We don't need to be careful with the 'w' mode as it will not overwrite into the file if it already exists. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 19. What is the difference between 'r' and 'rb' file modes? A) Both 'r' and 'rb' modes are used for reading text files only. B) The 'r' mode is for writing text files, and 'rb' is for writing binary files. C) The 'r' mode is for reading binary files, and 'rb' is for reading text files. D) The 'r' mode is for reading text files, and 'rb' is for reading binary files. Show Answer Correct Answer: D) The 'r' mode is for reading text files, and 'rb' is for reading binary files. 20. What is the description of the following file mode 'w+' A) Write and read. B) Write only. C) Read only. D) None. Show Answer Correct Answer: A) Write and read. 21. File formats are specified in the file name A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: B) FALSE. 22. Which mode is used to write to a file (overwriting if exists)? A) 'a'. B) 'r'. C) 'rw'. D) 'w'. Show Answer Correct Answer: D) 'w'. 23. Which library is used in Python for binary file serialization? A) Json. B) Struct. C) Pickle. D) Csv. Show Answer Correct Answer: C) Pickle. 24. Which function is used to unpickle data from a binary file? A) Pickle.read(). B) Pickle.load(). C) Pickle.dump(). D) Pickle.write(). Show Answer Correct Answer: B) Pickle.load(). 25. What is the root folder on Windows typically referred to as? A) Home folder. B) C:drive. C) System folder. D) Root directory. Show Answer Correct Answer: B) C:drive. 26. Which function is used to check if the end of a file has been reached? A) IsEOF(). B) EndOfFile(). C) EOF(). D) End(). Show Answer Correct Answer: C) EOF(). 27. How can you ensure data is read one line at a time from a file? A) Use READFILE, and specify you want lines. B) Read the entire file and split the data into lines in the program. C) Use a loop to read until EOF, capturing data line by line. D) It's not possible to read data one line at a time. Show Answer Correct Answer: C) Use a loop to read until EOF, capturing data line by line. 28. 'w' mode creates a new file if one did not exist at the specified location. A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: A) TRUE. 29. Apa yang akan terjadi jika Anda mencoba membaca dari file yang tidak ada? A) Program akan berjalan normal. B) Data akan ditulis ke file. C) File akan dibuat secara otomatis. D) Program akan menampilkan pesan kesalahan. Show Answer Correct Answer: D) Program akan menampilkan pesan kesalahan. 30. How do you append text to a file? A) Using the 'read()' function. B) Using the 'r' mode. C) Using the 'w' mode. D) Using the 'a' mode. Show Answer Correct Answer: D) Using the 'a' mode. 31. What is the purpose of the program in Program 13.2? A) Append text to the end of a file. B) Write characters to a file. C) Read integers from a file. D) Copy source file to destination file. Show Answer Correct Answer: D) Copy source file to destination file. 32. Which type of file format is used to store tabular data like in a spreadsheet? A) MP3. B) MOV. C) CSV. D) TXT. Show Answer Correct Answer: C) CSV. 33. How do you create a Fileinputstream object in Java? A) FileInputStream input = new FileInputStream("file.txt");. B) FileInputStream input = new FileInputStream(file);. C) FileInputStream input = new FileInputStream(file.txt);. D) FileInputStream input = new FileInputStream();. Show Answer Correct Answer: A) FileInputStream input = new FileInputStream("file.txt");. 34. Select the statement to open a file named MYDATA.txt in read and write mode. Let the file object name be myfile. A) Myfile=open("MYDATA.dat", "rb+"). B) Myfile=open("MYDATA.dat", "r+"). C) Myfile=open("MYDATA.dat", "r"). D) None of the above. Show Answer Correct Answer: B) Myfile=open("MYDATA.dat", "r+"). 35. Which method is used to write text to a file in Python? A) File.save(). B) File.read(). C) File.append(). D) File.write(). Show Answer Correct Answer: D) File.write(). 36. What method is used to read a file line by line? A) Using 'write()' method. B) Using 'read()' method. C) Using 'close()' method. D) Using 'readline()' method or iterating over the file object. Show Answer Correct Answer: D) Using 'readline()' method or iterating over the file object. 37. What is the function of the 'getline' method in C++ file handling? A) To read an entire line from the file. B) To write a line to the file. C) To check if the file is open. D) To read a single character from the file. Show Answer Correct Answer: A) To read an entire line from the file. 38. What method would you use to write a list of strings to a file? A) Use the 'write()' method to append strings to the file. B) Use the 'writelines()' method after opening the file in write mode. C) Utilize the 'print()' function to display strings on the console. D) Employ the 'save()' method to store strings in a database. Show Answer Correct Answer: B) Use the 'writelines()' method after opening the file in write mode. 39. In seek () you can move the file pointer in forward direction with the help of ..... values A) Positive values. B) Negative Values. C) None Value. D) Zero Value. Show Answer Correct Answer: A) Positive values. 40. What are the different modes of opening a file using Fileoutputstream in Java? A) Read mode. B) Update mode. C) 1. Create mode 2. Append mode. D) Delete mode. Show Answer Correct Answer: C) 1. Create mode 2. Append mode. 41. ..... helps in storing information. A) Data's. B) Hard Disk. C) Files. D) Pictures. Show Answer Correct Answer: C) Files. 42. Fungsi apa yang digunakan untuk menulis data terformat ke file? A) Fwrite. B) Fprintf. C) Fscanf. D) Fread. Show Answer Correct Answer: B) Fprintf. 43. What function is used to write a list of dictionaries to a csv file in Python? A) Dicts to csv(). B) Csv.writer. C) Writecsvdict(). D) Csv.write dicts. Show Answer Correct Answer: B) Csv.writer. 44. What does the '.write' method do? A) Reads data from a file. B) Opens a file for writing. C) Writes data to a file. D) Deletes data from a file. Show Answer Correct Answer: C) Writes data to a file. 45. Which memory is volatile memory? A) Hard Disk. B) CD. C) Pen drive. D) RAM. Show Answer Correct Answer: D) RAM. 46. A 1D array declaration can be written as: A) DECLARE StudMark:ARRAY[0:4] OF INTEGER. B) DECLARE StudMark:[0, 4] OF INTEGER. C) DECLARE StudMark:ARRAY[0, 4] OF INTEGER. D) DECLARE:ARRAY[0, 4] OF INTEGER. Show Answer Correct Answer: A) DECLARE StudMark:ARRAY[0:4] OF INTEGER. 47. What is the function "r" in file handling A) Read. B) Write. C) Append. D) None of the above. Show Answer Correct Answer: A) Read. 48. The following is an example of what type of error?prnt("Hello World") A) Syntax Error. B) Run-time Error. C) Semantic Error. D) None of the above. Show Answer Correct Answer: A) Syntax Error. 49. The default delimiter of the CSV file is ..... A) Filter. B) Comma. C) Tab. D) Colon. Show Answer Correct Answer: B) Comma. 50. Which of the following option is the correct Python statement to read and display the first 10 characters of a text file "Notes.txt" ? A) F =open('Notes.txt'); print(F.load(10)). B) F =open('Notes.txt'); print(F.write(10)). C) F = open('Notes.txt'); print(F.read(10)). D) F =open('Notes.txt'); print(F.dump(10)). Show Answer Correct Answer: C) F = open('Notes.txt'); print(F.read(10)). 51. What is the result of calling add ..... two(10, -5)? A) 5. B) 15. C) Error. D) None. Show Answer Correct Answer: A) 5. 52. What will happen if you try to open a non-existent file in "r" mode? A) A new file is created. B) The file is opened with no error. C) The program will raise a FileNotFoundError. D) The file will be created and opened. Show Answer Correct Answer: C) The program will raise a FileNotFoundError. 53. Differentiate between binary, CSV, and text files in Python. A) Binary files store data in a tabular format separated by commas. B) Text files store data in a binary format. C) CSV files contain data in a format that is not human-readable. D) Binary files contain data in a format that is not human-readable, CSV files store tabular data separated by commas, and text files store data as plain text without any specific formatting. Show Answer Correct Answer: D) Binary files contain data in a format that is not human-readable, CSV files store tabular data separated by commas, and text files store data as plain text without any specific formatting. 54. What does setting a Boolean variable to false indicate in file handling? A) File is corrupted. B) End of the file is reached. C) File is empty. D) End of the file is not reached. Show Answer Correct Answer: D) End of the file is not reached. 55. Which of the following packages contain classes and interfaces used for input & output operations of file? A) Java.io. B) Java.lang. C) Java.util. D) Java.net. Show Answer Correct Answer: A) Java.io. 56. What does calloc() do in C programming? A) Allocates memory and initializes it to zero. B) Allocates memory without initialization. C) Frees allocated memory. D) Resizes allocated memory. Show Answer Correct Answer: A) Allocates memory and initializes it to zero. 57. Which method is used to close the Stream? A) Flush();. B) Null();. C) Close();. D) Final();. Show Answer Correct Answer: C) Close();. 58. Ravi opened the file myfile.txt in append mode. In this file the file object/file handle will be at the ..... A) End of the file. B) The end of the first line. C) Second line of the file. D) Beginning of the file. Show Answer Correct Answer: A) End of the file. 59. What is the purpose of the 'data dependency' in the context of file handling? A) To compress the data in the file. B) To specify the order of data in the file. C) To ensure data is encrypted in the file. D) To separate data into different files. Show Answer Correct Answer: B) To specify the order of data in the file. 60. Which of the following operator is used for negation? A) !. B) Not. C) Both ! & not. D) None. Show Answer Correct Answer: C) Both ! & not. ← 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