This quiz works best with JavaScript enabled. Home > Cbse > Class 11 > Science > Computer Science > Class 11 Computer Science Chapter 6 File Handling – Quiz 22 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 22 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which exception is raised when a file is not found? A) ValueError. B) IOError. C) ImportError. D) FileNotFoundError. Show Answer Correct Answer: D) FileNotFoundError. 2. If you append something to a file it will appear: A) At the start of the file. B) At the end of the file. C) All the above. D) None of the above. Show Answer Correct Answer: B) At the end of the file. 3. What are the different file access methods? A) Sequential Access, Direct Access, Random Access. B) Stream Access. C) Buffered Access. D) File Access Method. Show Answer Correct Answer: A) Sequential Access, Direct Access, Random Access. 4. Full form of CSV file is ..... A) Comma Separated Value. B) Comma Separated Vault. C) Common Separated Value. D) Common System Value. Show Answer Correct Answer: A) Comma Separated Value. 5. Which is the correct syntax to open text file? A) Ofstreamobj.open( "abc.txt" );. B) Ofstreamobj:open( "abc.txt" );. C) Ofstreamobj.open(abc.txt);. D) Ofstreamobj::open( "abc.txt" );. Show Answer Correct Answer: D) Ofstreamobj::open( "abc.txt" );. 6. What is the purpose of using binary files? A) To compress data. B) To store data in a human-readable format. C) To create text files. D) To store data in its original format. Show Answer Correct Answer: D) To store data in its original format. 7. Which of the following is a correct way to create a new directory using pathlib? A) Os.mkdir('new folder'). B) Os.makedirs('new folder'). C) Path('new folder').mkdir(). D) Path('new folder').makedirs(). Show Answer Correct Answer: C) Path('new folder').mkdir(). 8. How can you append data to an existing file? A) Open the file in write mode and overwrite the data. B) Open the file in append mode and write the data. C) Delete the existing file and create a new one with the data. D) Open the file in read mode and write the data. Show Answer Correct Answer: B) Open the file in append mode and write the data. 9. To read from a file in python, which of the following is incorrect A) Filehandle.read([n]). B) Filehandle.readline([n]). C) Filehandle.readlines([n]). D) Filehandle.readlines([n]). Show Answer Correct Answer: C) Filehandle.readlines([n]). 10. What exception is raised if you try to open a file that does not exist in read mode? A) FileAccessError. B) FileMissingException. C) FileReadError. D) FileNotFoundError. Show Answer Correct Answer: D) FileNotFoundError. 11. The method to get the current position of the file marker. A) Told(). B) Tell(. C) Told(. D) Tell(). Show Answer Correct Answer: D) Tell(). 12. What is the code to open a file named as Updated ..... Data for output and move the read/write control to the end of the file? A) Open("Updated Data.dat", ios::ate). B) Open("Updated Data.dat" && ios::ate). C) Open("Updated Data.dat" | ios::ate). D) Open("Updated Data.dat" $ $ ios::ate). Show Answer Correct Answer: A) Open("Updated Data.dat", ios::ate). 13. Select the most appropriate format for load function. A) =pickle.load(). B) =pickle.load():. C) =pickle.load(). D) =pickle.load():. Show Answer Correct Answer: A) =pickle.load(). 14. Apa nama fungsi yang disediakan python standard library untuk membaca sebuah file txt? A) Load(). B) Read file(). C) Open(). D) Fetch(). Show Answer Correct Answer: C) Open(). 15. ..... function is used to write single row at a time. A) Writerows(). B) Writerow(). C) Writerecords(). D) Writelines(). Show Answer Correct Answer: B) Writerow(). 16. How to write binary data to a file? A) 'rb'. B) 'wb'. C) 'ab'. D) B and c. Show Answer Correct Answer: D) B and c. 17. What is the correct way to open a file for writing in Python? A) Open('file.txt', 'r'). B) Open('file.txt', 'w'). C) Open('file.txt', 'a'). D) Open('file.txt', 'x'). Show Answer Correct Answer: B) Open('file.txt', 'w'). 18. What does the 'is ..... absolute()' method check for in a Path object? A) If the path is a directory. B) If the path exists. C) If the path is valid. D) If the path is an absolute path. Show Answer Correct Answer: D) If the path is an absolute path. 19. What is the function of fputs()? A) Write a character to a file. B) Read a character from a file. C) Write a line to a file. D) Read a line from a fileread a character from a file. Show Answer Correct Answer: C) Write a line to a file. 20. The error encountered during the code being translating from human readable to machine code A) Syntax. B) Logical. C) Run time. D) All of the above. Show Answer Correct Answer: A) Syntax. 21. What type of variable can a file be considered as? A) File variable. B) Integer. C) Boolean. D) String. Show Answer Correct Answer: A) File variable. 22. Which function is used to read a character from a file? A) Filechar(). B) Getcfile(). C) Getchar(). D) Fgetc(). Show Answer Correct Answer: D) Fgetc(). 23. The ..... function removes the given character from both ends. A) Strip(). B) Lstrip(). C) Rstrip(). D) All these. Show Answer Correct Answer: A) Strip(). 24. What will be the output of the following Python code?lst = [1, 2, 3]lst[3] A) IndexError. B) TypeError. C) NameError. D) ValueError. Show Answer Correct Answer: A) IndexError. 25. Suresh wants to open the binary file student.dat in read mode. Which of the following modes should he use? A) Rb. B) W. C) Wb. D) R. Show Answer Correct Answer: A) Rb. 26. In Seek () ..... is a number specifying number of bytes. A) Nine of this. B) Mode. C) File object. D) Offset. Show Answer Correct Answer: D) Offset. 27. What is the purpose of fclose()? A) Closes an open file. B) Reads formatted input from a file. C) Checks for end of file. D) Opens a file. Show Answer Correct Answer: A) Closes an open file. 28. The ..... text file a specific character is stored to separate values A) Delimited text file. B) Binary File. C) Regular text file. D) CSV File. Show Answer Correct Answer: A) Delimited text file. 29. This command will open MyFile = open('MyText.txt', 'r') A) To write to the file. B) To read the file. C) To append to the file. D) None of the above. Show Answer Correct Answer: B) To read the file. 30. Which symbol is used for append mode? A) Ap. B) A. C) W. D) None of the above. Show Answer Correct Answer: B) A. 31. Which of the following is NOT a valid file access mode in Python? A) W. B) A. C) Z. D) R. Show Answer Correct Answer: C) Z. 32. What is the significance of the 'with' statement when handling files in Python? A) The 'with' statement is used to create new files in Python. B) The 'with' statement simplifies file handling by ensuring proper resource management. C) The 'with' statement allows for multiple files to be opened simultaneously without any issues. D) The 'with' statement is only necessary for reading files, not writing them. Show Answer Correct Answer: B) The 'with' statement simplifies file handling by ensuring proper resource management. 33. Which mode in file handling will create a file, if the file does not exist? A) R. B) W. C) A. D) NONE. Show Answer Correct Answer: B) W. 34. The command used to skip a row in a CSV file is A) Omit(). B) Skip(). C) Bounce(). D) Next(). Show Answer Correct Answer: D) Next(). 35. Which function is used to determine if a directory exists or not? A) Os.path.isfile(). B) Os.path.find(). C) Os.path.isdir(). D) Os.path.exists(). Show Answer Correct Answer: C) Os.path.isdir(). 36. What is the significance of using serialization in Java? A) It allows objects to be converted into a string for storage. B) It helps in sorting arrays in Java. C) It is used for creating random numbers in Java. D) It allows objects to be converted into a byte stream for storage or transmission. Show Answer Correct Answer: D) It allows objects to be converted into a byte stream for storage or transmission. 37. Which of the following function is used to write or store data (objects) to a binary file? A) Output(). B) Send(). C) Write(). D) Dump(). Show Answer Correct Answer: D) Dump(). 38. How do you read a file line by line in a loop? A) With open('filename.txt', 'r') as file:for line in file:print(line.strip()). B) For line in read(file):. C) With file('filename.txt') as f:. D) Open('filename.txt') as file:. Show Answer Correct Answer: A) With open('filename.txt', 'r') as file:for line in file:print(line.strip()). 39. How can you check if a file exists before opening it? A) Check 'os.file exists(file path)' for file existence. B) Employ 'os.path.isfile(file path)' to confirm file status. C) Use 'file.exists(file path)' to verify file presence. D) Use 'os.path.exists(file path)' to check if a file exists. Show Answer Correct Answer: D) Use 'os.path.exists(file path)' to check if a file exists. 40. Which of the following function is used to write data in binary mode? A) Output. B) Dump. C) Send. D) Write. Show Answer Correct Answer: B) Dump. 41. Which method is used to write a list of strings to a file? A) 'readlines()'. B) 'write()'. C) 'writelines()'. D) 'read()'. Show Answer Correct Answer: C) 'writelines()'. 42. Can opening a file in 'write' or 'append' mode create a new file? A) Neither 'write' nor 'append' mode can create a new file. B) In both 'write' and 'append' modes. C) Only in 'append' mode. D) Only in 'write' mode. Show Answer Correct Answer: B) In both 'write' and 'append' modes. 43. Which function is used to save a file A) End(). B) Save(). C) Close(). D) Stop(). Show Answer Correct Answer: C) Close(). 44. Which of the following is the correct syntax of file object 'fobj' to write sequence data type using writelines() function? A) Fobj.writelines(). B) Fobj.writeline(). C) File.writelines(sequence). D) Fobj.writelines(sequence). Show Answer Correct Answer: D) Fobj.writelines(sequence). 45. Which of these is correct to read one line of text file? A) Readlines(). B) Read(). C) Readfileline(). D) Readline(). Show Answer Correct Answer: A) Readlines(). 46. How to write a list of lines to a file? A) Write(list). B) Writeline(). C) Writelines(). D) Writeall(). Show Answer Correct Answer: C) Writelines(). 47. Which is CORRECT way to read all records from a binary file? A) Pickle.read(f). B) For rec in f:pickle.load(rec). C) F.load(). D) While True:rec=pickle.load(f). Show Answer Correct Answer: D) While True:rec=pickle.load(f). 48. The CSV files are popular because of ..... A) Easy to create. B) Easy to import and export. C) Capable of storing large data. D) All these. Show Answer Correct Answer: D) All these. 49. X = 5print(not(x > 3 and x < 10)) A) Not(x > 3 and x < 10). B) True. C) False. D) Syntax error. Show Answer Correct Answer: C) False. 50. What does fseek() do? A) Gets the current position of the file pointer. B) Checks for file errors. C) Resets the file position to the beginning. D) Sets the file position. Show Answer Correct Answer: D) Sets the file position. 51. Raise and assertion is a ..... A) Keyword. B) Statementt. C) Error. D) Both a and b. Show Answer Correct Answer: D) Both a and b. 52. A pointer variable contains as its value of another value. A) Void. B) Memory. C) Address. D) Pointer. Show Answer Correct Answer: B) Memory. 53. What is the difference between 'w' and 'a' file modes in Python? A) 'w' mode is used for reading and 'a' mode is used for writing. B) 'w' mode is used for appending and 'a' mode is used for writing. C) 'w' mode is used for reading and 'a' mode is used for appending. D) 'w' mode is used for writing and 'a' mode is used for appending. Show Answer Correct Answer: D) 'w' mode is used for writing and 'a' mode is used for appending. 54. Which line of code is correct for opening a file in write mode A) Leader file w = open( "leaderboard.txt" , "w" ). B) Leader file w = open(leaderboard.txt, "w" ). C) Leader file w = open( "leaderboard.txt" , "r" ). D) Open( "leaderboard.txt" , "w" ). Show Answer Correct Answer: A) Leader file w = open( "leaderboard.txt" , "w" ). 55. Which particular header file is necessary to perform file handling in C++ A) Conio.h. B) Math.h. C) Fstream.h. D) File.h. Show Answer Correct Answer: C) Fstream.h. 56. ..... is the process Of converting Python object hierarchy into a byte stream. A) Serialization. B) Seek(). C) Tell(). D) Un Pickling. Show Answer Correct Answer: A) Serialization. 57. In our computer all software and files are store in A) Hard Disk. B) CD. C) RAM. D) DVD. Show Answer Correct Answer: A) Hard Disk. 58. Public char[] readPassword() blongs to whcih class A) InputStreamReader class. B) Scanner Class. C) DataInputStream. D) Console class. Show Answer Correct Answer: D) Console class. 59. Information stored on a storage device with a specific name is called as A) File. B) Package. C) Module. D) Folder. Show Answer Correct Answer: A) File. 60. Which class is used for reading data from a file in C++? A) 'fstream'. B) 'ifstream'. C) 'ofstream'. D) 'iostream'. Show Answer Correct Answer: B) 'ifstream'. ← 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