This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 53 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 53 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What is the purpose of the 'writeline' function? A) To read a line from a file. B) To write a line to a file. C) To delete a line from a file. D) To close a file. Show Answer Correct Answer: B) To write a line to a file. 2. Which statement is true regarding the use of loops in file handling? A) For aLine in aFile statement can be used to iterate over a list. B) Loops cannot be used to read files. C) A loop is an efficient and clear way to read each line in a file until the end. D) Files should always be read in one go, not using loops. Show Answer Correct Answer: C) A loop is an efficient and clear way to read each line in a file until the end. 3. Which of the following statementscorrectly explain the function of seek() method? A) Tell the current position within the file. B) Indicate that the next read or write occurs from that position in a file. C) Determine if you can move the file position or not. D) Move the current file position to a different location at a defined offset. Show Answer Correct Answer: D) Move the current file position to a different location at a defined offset. 4. What is the extension for binary files? A) .csv. B) .CSV. C) .dat. D) .txt. Show Answer Correct Answer: C) .dat. 5. Class IT\{static public void main(String ..... args)\{int k=Integer.parseInt(args[0]);System.out.println(k);\}\}if args[0]="gec" then what type of exception is thrown by the above program. A) NumberFormatException. B) NullPointerException. C) ArrayIndexOutOfBoundsException. D) InvalidStringException. Show Answer Correct Answer: A) NumberFormatException. 6. Which function is used to move pointer to a specific byte? A) Move(). B) Seek(). C) Locate(). D) Position(). Show Answer Correct Answer: B) Seek(). 7. What is the difference between reading and writing to a file? A) Reading retrieves data, writing adds or updates data. B) Reading deletes data, writing appends data. C) Reading updates data, writing retrieves data. D) Reading adds data, writing retrieves and updates data. Show Answer Correct Answer: A) Reading retrieves data, writing adds or updates data. 8. Pointer to structure uses: A) Struct.p. B) P$\rightarrow$field. C) P.field. D) Struct$\rightarrow$field. Show Answer Correct Answer: B) P$\rightarrow$field. 9. What is the Binary file mode for the Description read and write? A) Rb. B) R+b or rb+. C) W+b or wb+. D) Wb. Show Answer Correct Answer: B) R+b or rb+. 10. What happens if you use fopen("newfile.txt", "w") on a non-existing file? A) PHP will show an error. B) The file will be deleted. C) The file will be created. D) Nothing will happen. Show Answer Correct Answer: C) The file will be created. 11. What will be the output of the following C code? #include int main() \{ FILE *fp = stdout; int n; fprintf(fp, "%d ", 45); fflush(stdout); fprintf(stderr, "%d", 65); return 0; \} A) Compilation error. B) 65 45. C) 45 65. D) 45. Show Answer Correct Answer: C) 45 65. 12. ..... is the inverse of Pickling where a byte stream is converted into an object hierarchy. A) Serialization. B) Un Pickling. C) Tell(). D) Seek(). Show Answer Correct Answer: B) Un Pickling. 13. Which of the following is not a known file type? A) ....dat. B) Csv. C) Bin. D) Txp. Show Answer Correct Answer: D) Txp. 14. What is a file path? A) Shows where a file is located. B) Defines the file type. C) Indicates the size of a file. D) A method to save files. Show Answer Correct Answer: A) Shows where a file is located. 15. What type of file access jumps directly to any piece of data in a file without reading the data that came before it? A) Sequential. B) Random. C) Number. D) Text. Show Answer Correct Answer: B) Random. 16. How do you change the file position to an offset value from the start? A) Fp.seek(offset, 0). B) Fp.seek(offset, 1). C) Fp.seek(offset, 2). D) None of the mentioned. Show Answer Correct Answer: A) Fp.seek(offset, 0). 17. Which of the following is a step in file handling? A) Open the file. B) Delete the file. C) Rename the file. D) Copy the file. Show Answer Correct Answer: A) Open the file. 18. What will be the output of the following code snippet?f=open('xyz.txt', 'r')x=f.read()f.close()print(x) A) Error(not writable). B) Error(not readable). C) It will read all the data of the file. D) None. Show Answer Correct Answer: C) It will read all the data of the file. 19. What is the output of the following code?def func(a, b=10, c=20):return a + b + cresult = func(5, c=15)print(result) A) 30. B) 25. C) 50. D) Error. Show Answer Correct Answer: A) 30. 20. What command can you use to send back data from a function? A) Return. B) Sendback. C) Back. D) Print(). Show Answer Correct Answer: A) Return. 21. Koju metodu koristimo za zatvaranje streama preko objekta file u C++? A) File.end();. B) File.close();. C) File.exit();. D) File.stop();. Show Answer Correct Answer: B) File.close();. 22. Which method in the csv module is used to write a single row to a csv file? A) Csv.writerow. B) Csv.write row. C) Writecsvrow(). D) Row to csv(). Show Answer Correct Answer: A) Csv.writerow. 23. Which function is used to open a file in C++ for reading or writing? A) OpenFile(). B) CreateFile(). C) Open(). D) Ofstream() / ifstream(). Show Answer Correct Answer: C) Open(). 24. What does the 'W' parameter signify in the 'open' command when opening a file in Python? A) Write to the file. B) Wait for input from the file. C) Wipe the file. D) Wrap the file. Show Answer Correct Answer: A) Write to the file. 25. Which module is used to serialize objects in Python? A) Os. B) Pickle. C) Json. D) Shelve. Show Answer Correct Answer: D) Shelve. ← 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