Ruby Logo

File & Data Management Quiz

Test your knowledge of Ruby file I/O, CSV/JSON/YAML processing, environment variables, and marshalling concepts.

Home Ruby File & Data Management Quiz

File & Data Management Quiz

Test your knowledge of Ruby's file I/O operations, CSV/JSON/YAML processing, environment variables, and marshalling. This comprehensive quiz covers practical scenarios and best practices you'll encounter in real-world Ruby development.

Quiz Progress

25 Questions | ~15 minutes

Complete all questions to see your results and detailed explanations.

File I/O Operations (8 questions)

1. What's the safest way to read a file in Ruby?

2. Which file mode should you use to append data to an existing file?

3. What does File.exist?("path/to/file") return if the path exists but is a directory?

4. Which Pathname method returns the file extension?

5. What's the most memory-efficient way to process a very large file line by line?

6. How do you create nested directories safely in Ruby?

7. What happens if you try to write to a file without proper permissions?

8. What's the difference between puts and write when writing to a file?

CSV, JSON & YAML Processing (6 questions)

9. How do you read a CSV file with headers and access columns by name?

10. What's the difference between JSON.parse and JSON.parse(str, symbolize_names: true)?

11. Which YAML loading method is safer for untrusted input?

12. What's the main advantage of CSV over JSON for tabular data?

13. How do you generate pretty-formatted JSON output?

14. What happens when you try to parse invalid JSON with JSON.parse?

Environment Variables (6 questions)

15. What's the difference between ENV["VAR"] and ENV.fetch("VAR")?

16. How do you convert an environment variable string to a boolean in Ruby?

17. What should you add to your .gitignore file when using .env files?

18. How do you temporarily set environment variables for a single command in Unix/Linux?

19. What's the recommended way to provide default values for environment variables?

20. What's the primary benefit of using environment variables over hardcoded configuration?

Marshalling & Serialization (5 questions)

21. What's the primary security risk with Marshal.load?

22. Which objects CANNOT be marshalled by default?

23. What's the purpose of implementing marshal_dump and marshal_load methods?

24. Which is the safest alternative to Marshal for external data?

25. What's a practical use case for deep cloning with Marshal?

Quick Navigation

Related Topics

Video Tutorial

Watch and learn file & data management quiz

Pro Tip: After reading through the content above, watch this video to reinforce your understanding and see the concepts in action!