What does the File.exist? method in Ruby return if the specified file exists?
A. 1
B. TRUE
C. 0
D. 1
Answer: Option B
Related Questions on File Input Output in Ruby
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