What does the 'a+' file mode in Ruby signify?
A. Opens a file for appending, creating it if it does not exist
B. Opens a file for writing, creating it if it does not exist
C. Opens a file for reading and writing, creating it if it does not exist
D. Opens a file for reading and appending, creating it if it does not exist
Answer: Option D
What does File.open() return in Ruby when the file is successfully opened?
A. Integer representing file descriptor
B. Array of file contents
C. Boolean value
D. File object
How do you open a file in Ruby in write mode, creating it if it does not exist?
A. File.create("filename.txt", "w")
B. File.write("filename.txt", "w")
C. File.open("filename.txt", "w")
D. File.new("filename.txt", "w")
What is the purpose of the File.readlines() method in Ruby?
A. To delete all lines from a file
B. To write all lines of a file from an array
C. To read all lines of a file into an array
D. To read a specific line from a file
Join The Discussion