This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 49 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 49 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Choose the right statement for fscanf() and scanf() A) Fscanf() can read from standard input whereas scanf() specifies a stream from which to read. B) Fscanf() can specifies a stream from which to read whereas scanf() can read only from standard input. C) Fscanf() and scanf() has no difference in their functions. D) Fscanf() and scanf() can read from specified stream. Show Answer Correct Answer: B) Fscanf() can specifies a stream from which to read whereas scanf() can read only from standard input. 2. What is the correct way to write to a file in Python? A) File = open('file.txt', 'w'). B) File = open('file.txt', 'r'). C) File = open('file.txt', 'a'). D) File = open('file.txt', 'x'). Show Answer Correct Answer: A) File = open('file.txt', 'w'). 3. Exception classes belongs to following package A) Import java.io.*. B) Import java.lang.*. C) Import java.util.*. D) Import java.lang.Exception.*. Show Answer Correct Answer: B) Import java.lang.*. 4. What is the correct function to read a specific number of bytes from an open file? A) Readfile(). B) Fread(). C) Fopen(). D) Fwrite(). Show Answer Correct Answer: B) Fread(). 5. What mode should be used to open a file for reading in Python? A) "r". B) "w". C) "a". D) "rb". Show Answer Correct Answer: A) "r". 6. What type of objects allow us to use the "with" term? A) Those that are related to files. B) Those with a close() method. C) Those that contain the obj definition. D) Only those that are variables. Show Answer Correct Answer: B) Those with a close() method. 7. A ..... governs the type of operations(eg read/write/append) possible in the opened file.The two types of data files can be ..... files and ..... files. A) FILEMODE, EXCEL, WORD. B) File Mode, read, write. C) Data, Text, record. D) File mode, Text, Data. Show Answer Correct Answer: D) File mode, Text, Data. 8. Files store data permanently in a/ an A) Storage device. B) Array. C) Function. D) Variable. Show Answer Correct Answer: A) Storage device. 9. Which of the following statements is correct regarding the seek() method? A) Sets the file position to the end of file. B) Position of file pointer remains unchanged. C) Sets the file's current position at the offset. D) The file pointer is set to the start of the file. Show Answer Correct Answer: C) Sets the file's current position at the offset. 10. Module used to read and write into binary files A) Dump. B) Load. C) Pickle. D) Open. Show Answer Correct Answer: C) Pickle. 11. In the data hierarchy, it is also considered as the Binary. A) Characters. B) Fields. C) Records. D) Bits. Show Answer Correct Answer: D) Bits. 12. What will be the output of the following C code? (Given that the size of array is 4 and new size of array is 5)#include#includemain()\{ int *p, i, a, b; printf("Enter size of array: "); scanf("%d", &a); p=(int*)malloc(a*sizeof(int)); for(i=0;i A) 0123. B) 01234. C) 01230. D) Error. Show Answer Correct Answer: C) 01230. 13. Which of the following functions do use use to write data in the binary format ..... A) Write(). B) Load(). C) Dump(). D) Seek(). Show Answer Correct Answer: C) Dump(). 14. Which function is used to read the content of Binary files? A) Dump(). B) Load(). C) Both a and b. D) None. Show Answer Correct Answer: B) Load(). 15. 'r' mode overwrites any data in the file A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: B) FALSE. 16. How can you write data to a text file in Python? A) Skip closing the file after writing. B) Open the file in read mode:file = open('filename.txt', 'r'). C) Open the file in write mode:file = open('filename.txt', 'w')Write data to the file:file.write('Hello, World!')Close the file:file.close(). D) Use file.append() method to write data. Show Answer Correct Answer: C) Open the file in write mode:file = open('filename.txt', 'w')Write data to the file:file.write('Hello, World!')Close the file:file.close(). 17. Which mode will create a file only if it doesn't already exist? A) 'r'. B) 'a'. C) 'w'. D) 'x'. Show Answer Correct Answer: D) 'x'. 18. Assertion:Python is said to have broadly two types of files-binary and text files, even when there are CSV and TSV files also Reason:The CSV and TSV are types of delimited text only where the delimiters are common and tab respectively. 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) A is true but R is false (or partly true). D) A is false (or partly true) but R is true. Show Answer Correct Answer: A) Both A and R are true and R is the correct explanation of A. 19. If file is opened in "ab" mode, what happens? A) Overwrites file. B) Appends binary data at end. C) Reads and writes. D) Error. Show Answer Correct Answer: B) Appends binary data at end. 20. Which keyword is used to catch exceptions in Python? A) Try. B) Except. C) Finally. D) Raise. Show Answer Correct Answer: B) Except. 21. In Python how many function that help you manipulate the position of file pointer A) 1. B) 2. C) 3. D) 4. Show Answer Correct Answer: B) 2. 22. What will happen if you try to open a non-existent file in read mode? A) A new file will be created. B) The file will be opened in write mode. C) The program will raise an error. D) The file will be opened successfully. Show Answer Correct Answer: C) The program will raise an error. 23. How do you read a specific row from a CSV file? A) Read the CSV using NumPy and select the row with np.row[row index]. B) Use CSV reader to load the file and print the row directly. C) Use pandas to read the CSV and access the row with df.iloc[row index]. D) Open the CSV in Excel and manually find the row you need. Show Answer Correct Answer: B) Use CSV reader to load the file and print the row directly. 24. With open("hello.txt", "w") as f:f.write("Hello World how are you today") with open('hello.txt', 'r') as f:data = f.readlines() for line in data:words = line.split() print (words) f.close() A) Runtime Error. B) Hello World how are you today. C) ['Hello', 'World', 'how', 'are', 'you', 'today']. D) Hello. Show Answer Correct Answer: C) ['Hello', 'World', 'how', 'are', 'you', 'today']. 25. What is the data type of data read from a file? A) String. B) Integer. C) Real. D) Boolean. Show Answer Correct Answer: A) String. ← PreviousNext →Related 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 8Class 11 Computer Science Chapter 6 File Handling Quiz 9Class 11 Computer Science Chapter 6 File Handling Quiz 10 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books