This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 15 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 15 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which exception is thrown by read() method? A) SystemException. B) IOException. C) InterruptedException. D) SystemInputException. Show Answer Correct Answer: B) IOException. 2. How do you create an array in PHP? A) $ cars = array("Volvo", "BMW", "Toyota");. B) $ cars = "Volvo", "BMW", "Toyota";. C) $ cars = array["Volvo", "BMW", "Toyota"];. D) None. Show Answer Correct Answer: A) $ cars = array("Volvo", "BMW", "Toyota");. 3. Di poster "Hierarki Stream File C++", mana stream untuk terminal? A) MyFile dan open. B) Ifstream dan ofstream. C) Fstream dan cout. D) Cin dan cout. Show Answer Correct Answer: D) Cin dan cout. 4. Consider:f=open("data.txt", "r")print(f.readline(4))If file contains "Python", output will be: A) "Pyth". B) "Python". C) "Py". D) Error. Show Answer Correct Answer: A) "Pyth". 5. Which of these keywords must be used to monitor for exceptions? A) Try. B) Finally. C) Throw. D) Catch. Show Answer Correct Answer: A) Try. 6. The type of operation possible in an opened file is governed by A) File Path. B) Open() Method. C) File Mode. D) File Object. Show Answer Correct Answer: C) File Mode. 7. Which of the following statements correctly explain the function of tell() method? A) Move the current file position to a different location. B) Tells the current position within the file. C) It changes the file position only if allowed to do so else returns an error. D) None. Show Answer Correct Answer: B) Tells the current position within the file. 8. What is the significance of the 'b' mode in file handling? A) The 'b' mode compresses files to save space. B) The 'b' mode allows for binary file handling, ensuring data integrity for non-text files. C) The 'b' mode is exclusive to image files. D) The 'b' mode is used for text file handling only. Show Answer Correct Answer: B) The 'b' mode allows for binary file handling, ensuring data integrity for non-text files. 9. A file object is also known as? A) File object. B) File pointer. C) File handle. D) Text file. Show Answer Correct Answer: C) File handle. 10. Which Python module helps with file path manipulations? A) Os. B) Path. C) Io. D) Sys. Show Answer Correct Answer: A) Os. 11. What is the output of:b=2c=2print(b is c)c +=2print(b is c) A) TrueFalse. B) TrueTrue. C) FalseFalse. D) FalseTrue. Show Answer Correct Answer: A) TrueFalse. 12. What does the 'EOF()' function return when the end of a file has NOT been reached? A) NULL. B) -1. C) TRUE. D) FALSE. Show Answer Correct Answer: D) FALSE. 13. In Which file the data get stored in tabular format? A) Text file. B) Binary file. C) Csv file. D) Both (a) and (c). Show Answer Correct Answer: C) Csv file. 14. Which Tkinter widget is used for multi-line text input? A) Slider. B) Text Widget. C) Label. D) Button. Show Answer Correct Answer: B) Text Widget. 15. The ..... function forces the writing of data on disc stil pending in output buffer. A) Flush(). B) Seek(). C) Load(). D) Dump(). Show Answer Correct Answer: A) Flush(). 16. In which format Binary file contains information A) Same format in which the data is held in memory. B) Quick response code. C) ASCII. D) Unicode. Show Answer Correct Answer: A) Same format in which the data is held in memory. 17. What precautions should be taken while working with Binary File Handling in Python? A) Ensure to open files in binary mode, handle exceptions, close files after operations, avoid mixing modes, and use proper encoding/decoding. B) Always mix modes when opening files. C) Ignore exceptions while working with files. D) Use incorrect encoding/decoding methods. Show Answer Correct Answer: A) Ensure to open files in binary mode, handle exceptions, close files after operations, avoid mixing modes, and use proper encoding/decoding. 18. Which option is True, in reference to the the 'a' and 'w' mode in open()? A) A and w are the same. B) A means overwrite the previous contents, w means append to the end of file. C) A means read all the contents of the file, w means write to the file. D) A means append to the end of file, w means overwrite the previous contents. Show Answer Correct Answer: D) A means append to the end of file, w means overwrite the previous contents. 19. The sys.stdin is always opened in ..... mode. A) Read. B) Write. C) Append. D) Read and Write. Show Answer Correct Answer: A) Read. 20. Default file opening mode is ..... A) Write. B) Read and write. C) Read. D) Append. Show Answer Correct Answer: C) Read. 21. Which method is used to read the entire content of a text file in a single string? A) Read(). B) Readline(). C) Readlines(). D) Both a and c. Show Answer Correct Answer: A) Read(). 22. In Python, which keyword is used to read data from a file? A) Read. B) Open. C) Write. D) Close. Show Answer Correct Answer: A) Read. 23. What does remove() do? A) Deletes a file. B) Opens a file. C) Renames a file. D) Writes data to a file. Show Answer Correct Answer: A) Deletes a file. 24. Which of the following statements is/are true? A) When you open a file for reading, if the file does not exist, an error occurs. B) When you open a file for writing, if the file does not exist, a new file is created. C) When you open a file for writing, if the file exists, the existing file is overwritten with the new file. D) All of the above. Show Answer Correct Answer: D) All of the above. 25. A structure can contain: A) Arrays. B) Pointers. C) Other structures. D) All. Show Answer Correct Answer: D) All. 26. How does the 'continue' statement affect the flow of a loop in C++? A) Terminates the loop immediately. B) Skips the current iteration and proceeds with the next one. C) Pauses the loop temporarily. D) None of the above. Show Answer Correct Answer: B) Skips the current iteration and proceeds with the next one. 27. What is the use of the 'open()' function in file handling? A) To initialize a variable. B) To create a new directory. C) To open a file for reading or writing. D) To close a file. Show Answer Correct Answer: C) To open a file for reading or writing. 28. Apa yang dilakukan fungsi fwrite? A) Menghapus file. B) Menutup file. C) Menulis blok data ke file. D) Membaca data dari file. Show Answer Correct Answer: C) Menulis blok data ke file. 29. When is the finally block executed? A) Never. B) When no exception occurs. C) Always. D) When an exception occurs. Show Answer Correct Answer: C) Always. 30. What is the purpose of the 'ofstream' class in C++? A) To handle standard input. B) To handle standard output. 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. 31. The correct syntax for converting the string x to uppercase is: A) X.upper(). B) Upper(x). C) X.UPPER[ ]. D) X.upper(). Show Answer Correct Answer: A) X.upper(). 32. Which of these class is highest in hierarchy in java A) Java.lang.Exception. B) Java.lang.Object. C) Java.lang.Throwable. D) Java.lang.Error. Show Answer Correct Answer: B) Java.lang.Object. 33. How do you open a binary file in Python? A) Open('filename', 'r'). B) Open('filename', 'wb'). C) Open('filename', 'rb'). D) Open('filename', 'a'). Show Answer Correct Answer: C) Open('filename', 'rb'). 34. Which of the following mode argument is used to truncate? A) R. B) W. C) A. D) All of the above. Show Answer Correct Answer: B) W. 35. Can one except block handle multiple exceptions? A) Yes. B) May be. C) Insufficient information. D) No. Show Answer Correct Answer: A) Yes. 36. During a school project, Reyansh, Taran, and Tanisha need to save their data into a CSV file. Which method should they use to write multiple rows in one call? A) Writeall(). B) BulkInsert(). C) AddRows(). D) Writerows(). Show Answer Correct Answer: D) Writerows(). 37. Differentiate between a text file and a binary file in C++. A) A text file is always larger in size than a binary file. B) A text file can only be opened in read mode, while a binary file can only be opened in write mode. C) A text file contains human-readable characters, while a binary file contains machine-readable data in the form of 0s and 1s. D) A text file contains only numbers, while a binary file contains only letters. Show Answer Correct Answer: C) A text file contains human-readable characters, while a binary file contains machine-readable data in the form of 0s and 1s. 38. Why we use file handling? A) To store input output data permanently. B) It facilitates us to cut, copy, paste files. C) To create folders. D) To store input output data temporarily. Show Answer Correct Answer: A) To store input output data permanently. 39. How do you read specific columns from a CSV file using pandas? A) Import pandas as pddf = pd.read csv('file.csv', usecols=['column1', 'column2']). B) Df = pd.read csv('file.csv', select=['column1', 'column2']). C) Df = pd.read csv('file.csv', readcols=['column1', 'column2']). D) Df = pd.read csv('file.csv', columns=['column1', 'column2']). Show Answer Correct Answer: A) Import pandas as pddf = pd.read csv('file.csv', usecols=['column1', 'column2']). 40. Which keyword creates a structure? A) Struct. B) Class. C) Record. D) Structure. Show Answer Correct Answer: A) Struct. 41. File in python is treated as sequence of ..... ? A) Bytes. B) Bites. C) All the above. D) None of the above. Show Answer Correct Answer: A) Bytes. 42. A variable defined between two functions A) Formal variable. B) Enclosed Variable. C) Nested variable. D) Local variable. Show Answer Correct Answer: B) Enclosed Variable. 43. What will be the position of File pointer after executing the following command?F.seek(-10, 2) A) 10 Characters behind from end of the file. B) 10 Characters ahead from current position of the file pointer. C) 10 Characters ahead from beginning of the file. D) 10 Characters behind from current position of the file pointer. Show Answer Correct Answer: A) 10 Characters behind from end of the file. 44. What is the Output of following program#include int fun(int n){ static int s = 0; s = s + n; return (s); }int main(){ int i = 10, x; while (i > 0) { x = fun(i); i ..... ; } printf ("%d ", x); return 0; } A) 0. B) 55. C) 110. D) 100. Show Answer Correct Answer: B) 55. 45. What is the purpose of the fopen() function in PHP? A) To open a file for reading or writing. B) To create a new directory. C) To close an open file. D) To delete a file. Show Answer Correct Answer: A) To open a file for reading or writing. 46. What type of file contains only ASCII code? A) Executable files. B) Image files. C) Binary files. D) Text files. Show Answer Correct Answer: D) Text files. 47. What is the purpose of the 'F' variable in the Python file handling examples? A) To store the file type. B) To store the file contents. C) To store the file name. D) To store the file size. Show Answer Correct Answer: B) To store the file contents. 48. N= int(input("Please enter an integer: "))if n < 0:raise Exception (" Only Positive Numbers are Allowed ") print ("Great, you successfully entered an integer!")what is the output if the given input is-12 A) Great, you successfully entered an integer!. B) Only Positive Numbers are Allowed. C) Only Positive Numbers are Allowed Great, you successfully entered an integer!. D) None of the above Option. Show Answer Correct Answer: B) Only Positive Numbers are Allowed. 49. ..... is used to read and write data to a file on disk. A) File Object. B) Modes. C) Nono of this. D) Raw String. Show Answer Correct Answer: A) File Object. 50. What will be the output of print(5/0)? A) NaN. B) Infinity. C) 5. D) ZeroDivisionError. Show Answer Correct Answer: D) ZeroDivisionError. 51. What are the two built-in functions to read a line of text from standard input, which is by default the keyboard? A) Input. B) Read. C) Scanner. D) None of the above. Show Answer Correct Answer: A) Input. 52. You need to be on "r" mode in order to read from a file. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 53. This method replaces a string with another string. A) Replace(). B) Lower(). C) Strip(). D) Upper(). Show Answer Correct Answer: A) Replace(). 54. Which of the following function is used to open the file in python file handling? A) Unfold(). B) Extend(). C) Open(). D) Unlock(). Show Answer Correct Answer: C) Open(). 55. What is the difference between a module and a package in Python? A) Packages are collections of modules. B) There is no difference. C) Modules are collections of packages. D) Packages contain a single module. Show Answer Correct Answer: A) Packages are collections of modules. 56. What does the function add ..... two(a, b) do? A) It takes two numbers and returns their sum. B) It subtracts two numbers. C) It multiplies two numbers. D) It divides two numbers. Show Answer Correct Answer: A) It takes two numbers and returns their sum. 57. Assertion:Exception handling handles all types of errors and exceptions.Reasoning:Exception handling is responsible for handling anomalous situations during the execution of a program. A) Both A and R are true and R is the correct explanation of A. B) Both A and R are true and R is not the correct explanation of A. C) Assertion is True but the Reason is False. D) Both the Assertion and Reason is False. Show Answer Correct Answer: A) Both A and R are true and R is the correct explanation of A. 58. How do you open a file in Python? A) Close(). B) Read(). C) Write(). D) Open(). Show Answer Correct Answer: D) Open(). 59. Which mode is used to open binary file in write read mode A) Rb+. B) Rw+. C) Wb+. D) Rwb+. Show Answer Correct Answer: C) Wb+. 60. What is the main advantage of using binary files over text files? A) Efficiency in storage and processing speed. B) Higher level of security for sensitive data. C) Easier to edit and modify the content. D) Better compatibility with different operating systems. Show Answer Correct Answer: A) Efficiency in storage and processing speed. ← 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