11. What is the purpose of the File.exist? method in Ruby? A. To check if the specified file is empty B. To check if the specified file is readable C. To check if the specified file is writable D. To check if the specified file exists Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
12. Which method in Ruby is used to set the position of the file pointer? A. seek() B. position() C. set_pointer() D. pointer_position() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
13. What does the File.rename() method in Ruby do? A. Creates a file B. Deletes a file C. Copies a file D. Renames a file Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
14. How do you read the entire contents of a file into a string in Ruby? A. file.gets() B. file.readlines() C. file.read() D. file.each_line() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
15. Which method in Ruby is used to delete a file? A. File.erase() B. File.delete() C. File.clear() D. File.erase() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
16. What is the purpose of the File.size method in Ruby? A. To determine the number of characters in a file B. To determine the last modification time of a file C. To determine the size of a file in bytes D. To determine the number of lines in a file Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
17. What is the result of using File.open() with the block syntax in Ruby? A. The file remains open after the block is executed B. The file is opened in write mode C. The file is opened in read mode D. The file is automatically closed at the end of the block Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
18. What does the 'w' file mode in Ruby signify? A. Opens a file for writing, truncating it if it exists B. Opens a file for reading and writing, creating it if it does not exist C. Opens a file for reading, creating it if it does not exist D. Opens a file for appending, creating it if it does not exist Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
19. How do you check if a file in Ruby is readable? A. File.writable("filename.txt") B. File.readable("filename.txt") C. File.writable?("filename.txt") D. File.readable?("filename.txt") Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
20. What method is used to check if a file is writable in Ruby? A. File.writable?("filename", "w") B. File.writable?("filename", "r") C. File.writable?("filename") D. File.writable?("filename", "rw") Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board