This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 7 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 7 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What exception is raised when trying to open a non-existent file? A) FileAccessError. B) FileNotFoundError. C) NoSuchFileError. D) FileMissingException. Show Answer Correct Answer: B) FileNotFoundError. 2. What is the outcome if you open a file in 'WRITE' mode and the file already contains data? A) The existing data is kept, and new data is added. B) The existing data is deleted, and new data is written. C) The existing data is locked. D) An error occurs. Show Answer Correct Answer: B) The existing data is deleted, and new data is written. 3. Apa tipe data yang akan dikembalikan oleh fungsi numpy.loadtxt()? A) Dictionary. B) DataFrame. C) String. D) Ndarray. Show Answer Correct Answer: D) Ndarray. 4. What is the purpose of the 'write lines' method in Python file handling? A) Writes a structure such as a list to a file. B) Writes the entire file at once. C) Writes a single line to the file. D) Writes a specific line to the file. Show Answer Correct Answer: A) Writes a structure such as a list to a file. 5. .... function is used to write data in a binary file A) Pickle.load(). B) Pickle.writeline(). C) Pickle.write(). D) Pickle.dump(). Show Answer Correct Answer: D) Pickle.dump(). 6. File object is reference to a file. It is used to read and write data to a file. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 7. Which one of the following databases has PHP supported almost since the beginning? A) SQL. B) MySQL. C) Oracle Database. D) None. Show Answer Correct Answer: B) MySQL. 8. What method is used to write data to a CSV file? A) Use a text editor to manually enter data. B) Utilize a database management system for CSV output. C) Save data as a JSON file instead. D) Use a CSV writing library or function, such as Python's 'csv.writer'. Show Answer Correct Answer: D) Use a CSV writing library or function, such as Python's 'csv.writer'. 9. What does the "b" mode specify when opening a file in Python? A) Backup mode. B) Buffer mode. C) Byte mode. D) Binary mode. Show Answer Correct Answer: D) Binary mode. 10. What mode would you use to append data to an existing file? A) Rw. B) A. C) W. D) R. Show Answer Correct Answer: B) A. 11. What must a program do before reading or writing to a file? A) Open the file in the appropriate mode. B) Close all other files in the system. C) Copy the file contents into an array. D) Convert the file into binary format. Show Answer Correct Answer: A) Open the file in the appropriate mode. 12. Why is it important to close the file when file handling? A) The program will crash. B) The content will be lost. C) Uses up a lot of memory. D) It wont work if you dont. Show Answer Correct Answer: C) Uses up a lot of memory. 13. Which is data type of file pointer? A) Int. B) Double. C) File. D) Float. Show Answer Correct Answer: C) File. 14. ..... & ..... statements together can handle runtime exceptions. A) Try & Except. B) Dump & Load. C) Seek & Tell. D) None of the above. Show Answer Correct Answer: A) Try & Except. 15. What does feof(fp) check? A) End of file reached. B) File exists. C) File empty. D) File format. Show Answer Correct Answer: A) End of file reached. 16. Closing files is important because it frees up RAM for other files and programs A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: A) TRUE. 17. Which of these is associated with a specific file and provides a way for the program to work with that file? A) Filename. B) Extension. C) File object. D) File variable. Show Answer Correct Answer: C) File object. 18. Apa nama method yang digunakan untuk menutup sebuah file yang terbuka di Python? A) Stop(). B) End(). C) Close(). D) Finish(). Show Answer Correct Answer: C) Close(). 19. What method should be called to close a FileWriter after writing? A) Finish(). B) Close(). C) Terminate(). D) End(). Show Answer Correct Answer: B) Close(). 20. Which of the following will read entire content of file(file object 'f')? A) F.reads(). B) F.read(all). C) F.read(). D) None of the above. Show Answer Correct Answer: C) F.read(). 21. What happens if you open a file in 'w' mode that already exists? A) Overwrites content. B) Appends to content. C) Reads content. D) Error. Show Answer Correct Answer: A) Overwrites content. 22. What is a CSV file? A) A text file format for programming code. B) A file format for audio data. C) A binary file format for images. D) A file format for data storage organized with records on each line. Show Answer Correct Answer: D) A file format for data storage organized with records on each line. 23. When we read from a file, what type of value do we get returned to us, by default? A) Int. B) Bool. C) Str. D) Float. Show Answer Correct Answer: C) Str. 24. Which of the following is the correct way of declaring a float pointer? A) Float ptr. B) Float * ptr. C) *float ptr. D) Float ptr*. Show Answer Correct Answer: B) Float * ptr. 25. In the data hierarchy, which of the choices is described as 'single values of letter or numbers'? A) Records. B) Bits. C) File. D) Characters. Show Answer Correct Answer: D) Characters. 26. Which mode create new file if the file does not exist? A) Write mode. B) Append mode. C) Both. D) None of the above. Show Answer Correct Answer: C) Both. 27. Is there a delimiter for binary files A) Yes. B) No. C) All the above. D) None of the above. Show Answer Correct Answer: B) No. 28. Which file execute faster? A) Text file. B) Binary file. C) CSV file. D) None of the above. Show Answer Correct Answer: B) Binary file. 29. Apa yang dilakukan ios::app? A) Membaca dari awal file. B) Mengunci file agar tidak dibuka. C) Menimpa seluruh file. D) Menambah di akhir file. Show Answer Correct Answer: D) Menambah di akhir file. 30. Which of the following is not a valid mode for opening a binary file? A) Rb+. B) Rw. C) Wb+. D) Ab. Show Answer Correct Answer: B) Rw. 31. What utility allows you to manage packages from the command line? A) Pip. B) Mpc. C) Pkg. D) Util. Show Answer Correct Answer: A) Pip. 32. Which of the following commands can be used to read the next line in a file using the file object ? A) Tmpfile.readline(). B) Tmpfile.read(n). C) Tmpfile.read(). D) Tmpfile.readlines(). Show Answer Correct Answer: A) Tmpfile.readline(). 33. Describe how to read a specific column from a CSV file. A) Convert the CSV to JSON and access the column from the JSON object. B) Read the CSV file as a text file and search for the column manually. C) Use pandas to read the CSV and access the column by its name. D) Use Excel to open the CSV and copy the column data. Show Answer Correct Answer: C) Use pandas to read the CSV and access the column by its name. 34. Which of the following codes will open a file named as Sample for reading and writing purposes? A) Open(ios::out | ios::in, "Sample.dat" );. B) Open("Sample.dat", ios::out | ios::in );. C) Open("Sample.dat", ios::out && ios::in );. D) Open(ios::out && ios::in, "Sample.dat" );. Show Answer Correct Answer: B) Open("Sample.dat", ios::out | ios::in );. 35. What is the purpose of the seek() function in file handling? A) To close the file. B) To read the file content. C) To delete the file. D) To change the current file position to the specified offset. Show Answer Correct Answer: D) To change the current file position to the specified offset. 36. What does the 'read()' method do when used on a file object? A) Returns the entire contents of the file as a string. B) Reads a single line from the file. C) Writes a string to the file. D) Returns a list of lines in the file. Show Answer Correct Answer: A) Returns the entire contents of the file as a string. 37. ..... returns a writer object which writes data into CSV file. A) Csv.writer()='w+'. B) Csv.writer(). C) Csv.writer():. D) Csv.writer()=import. Show Answer Correct Answer: B) Csv.writer(). 38. A class which is capable of creating files and writing information to files is called A) Iostream. B) Fstream. C) Ifstream. D) Ofstream. Show Answer Correct Answer: D) Ofstream. 39. Mode in the following program to open file for writing in a mode where new data will be added at the end of old datafile =open("poem.txt", " ..... ") A) A. B) R. C) X. D) W. Show Answer Correct Answer: A) A. 40. Which function deletes a file? A) Os.remove(). B) Delete(). C) Removefile(). D) File.delete(). Show Answer Correct Answer: A) Os.remove(). 41. What will be the output of the followingfrom import factorialprint(math.factorial(5)) A) 25. B) 10. C) 120. D) Error bcz factorial is not a module in math. Show Answer Correct Answer: D) Error bcz factorial is not a module in math. 42. What are the advantages of using Fileinputstream and Fileoutputstream in Java? A) They are not compatible with Java serialization. B) They provide high-level access to the file system, making file handling more complicated. C) They provide low-level access to the file system, allowing for efficient and flexible file handling. D) They are slower and less efficient than other file handling methods. Show Answer Correct Answer: C) They provide low-level access to the file system, allowing for efficient and flexible file handling. 43. What does this do? .split() A) Casts an integer to a string. B) Splits all characters up into individual elements. C) Splits the by the . D) Chars split peas. Show Answer Correct Answer: C) Splits the by the . 44. Which is not a text file? A) Data.mp3. B) Data.csv. C) Data.rft. D) Data.txt. Show Answer Correct Answer: A) Data.mp3. 45. Evaluate the following expressions:6 * 3 + 8**4 // 5-8 A) 13.2. B) 12. C) 11. D) 13. Show Answer Correct Answer: D) 13. 46. Which of the following is not a valid attribute of a file object (fp)? A) Fp.size. B) Fp.mode. C) Fp.closed. D) Fp.name. Show Answer Correct Answer: A) Fp.size. 47. Which method is used to rename a file in Python? A) File.rename(). B) ChangeFileName(). C) Os.rename(). D) Rename.file(). Show Answer Correct Answer: C) Os.rename(). 48. What is the function of putc() in C programming? A) Read a character from a file. B) Read a line from a file. C) Write a line to a file. D) Write a character to a file. Show Answer Correct Answer: D) Write a character to a file. 49. What is the purpose of the glob() method in pathlib? A) To list all files matching a specific pattern. B) To create a new file. C) All the above. D) None of the above. Show Answer Correct Answer: A) To list all files matching a specific pattern. 50. Which of the following is modes of both writing and reading in binary format in file? A) Wb. B) Wb+. C) W+. D) W. Show Answer Correct Answer: B) Wb+. 51. What is the extension of binary file? A) .nib. B) .bin. C) .dta. D) .dat. Show Answer Correct Answer: D) .dat. 52. To remove the spaces present at start and end of the string, you can use A) Strip(). B) Remove(). C) Split(). D) Len(). Show Answer Correct Answer: A) Strip(). 53. What is the purpose of using 'rb' mode when opening a binary file in Python? A) It indicates that the file is being opened in write mode for binary data. B) It signifies that the file is being opened in append mode for binary data. C) It specifies that the file is being opened in read mode for text data. D) It signifies that the file is being opened in read mode specifically for binary data. Show Answer Correct Answer: D) It signifies that the file is being opened in read mode specifically for binary data. 54. How can programs ensure that data is not lost when they are closed? A) By storing data in external files. B) By using temporary variables. C) By deleting unused data. D) By ignoring data preservation. Show Answer Correct Answer: A) By storing data in external files. 55. Which file contains information in the same format as it is stored in memory? A) Text File. B) Binary File. C) CSV File. D) All Files. Show Answer Correct Answer: B) Binary File. 56. Delimiters, such as (, :; t | ) are present in A) Text file. B) CSV files. C) Binary files. D) All of the above. Show Answer Correct Answer: B) CSV files. 57. Which method would you use to read a file line by line in Python? A) Readfile(). B) Readlines(). C) Readline(). D) Read(). Show Answer Correct Answer: C) Readline(). 58. In seek()-mode 1 will indicate. A) Current Position of File. B) BOF. C) Pointer Value. D) EOF. Show Answer Correct Answer: A) Current Position of File. 59. What is the purpose of the 'close()' method? A) To write data to a file. B) To open a file. C) To read data from a file. D) To terminate all resources in use. Show Answer Correct Answer: D) To terminate all resources in use. 60. It describe how to access a given file or directory, starting from the root of the file system. A) Relative file path. B) Absolute file path. C) Root file path. D) None. Show Answer Correct Answer: B) Absolute file path. ← 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 8Class 11 Computer Science Chapter 6 File Handling Quiz 9 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books