← All topics
Quiz: File Handling in Java: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Which classes should you use to copy a JPG image file?
- Q2. What does this print? (code)
- Q3. What does BufferedReader.readLine() return at the end of the file?
- Q4. Why is readAllLines a bad choice for a 5 GB log file?
- Q5. What is the main benefit of a buffered reader or writer?
- Q6. What does this print? (code)
- Q7. You write lines with a BufferedWriter but never close or flush it. What can happen?
- Q8. Why must Files.lines(path) be used inside try-with-resources?
- Q9. What does this print? (code)
- Q10. What is the difference between Files.list(dir) and Files.walk(dir)?