21. How do you check the size of a file in Ruby? A. Using File.bytes method B. Using File.size method C. Using File.sizeof method D. Using File.bytes method 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
22. Which method is used to delete a file in Ruby? A. File.erase("filename") B. File.destroy("filename") C. File.delete("filename") D. File.remove("filename") 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
23. What does the binmode method do in Ruby file I/O? A. Sets the file mode to text mode B. Sets the file mode to read-only mode C. Sets the file mode to write-only mode D. Sets the file mode to binary mode 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
24. How can you check if a file is readable in Ruby? A. Using File.readable? method B. Using File.can_read? method C. Using File.open("filename", "r") method D. Using File.read method 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
25. What does the truncate method do in Ruby file I/O? A. Truncates the file to the end of the file B. Truncates the file to the beginning of the file C. Truncates the file to the current position of the file pointer D. Truncates the file to a specified size 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
26. Which method is used to check if a file is executable in Ruby? A. File.can_execute?("filename") B. File.is_executable?("filename") C. File.executable?("filename") D. File.runnable?("filename") 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
27. How can you get the absolute path of a file in Ruby? A. Using File.real_path method B. Using File.expand_path method C. Using File.path method D. Using File.real_path method 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
28. What does the fcntl method do in Ruby file I/O? A. Changes file permissions B. Retrieves file attributes C. Manipulates file descriptor D. Modifies file content 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
29. How do you create a new directory in Ruby? A. Using Dir.create method B. Using Dir.new method C. Using Dir.make method D. Using Dir.mkdir method 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
30. What is the purpose of the chown method in Ruby file I/O? A. Changes the file attributes B. Changes the file timestamp C. Changes the file owner and group D. Changes the file permissions 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