🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. Which classes should you use to copy a JPG image file?
  2. Q2. What does this print? (code)
  3. Q3. What does BufferedReader.readLine() return at the end of the file?
  4. Q4. Why is readAllLines a bad choice for a 5 GB log file?
  5. Q5. What is the main benefit of a buffered reader or writer?
  6. Q6. What does this print? (code)
  7. Q7. You write lines with a BufferedWriter but never close or flush it. What can happen?
  8. Q8. Why must Files.lines(path) be used inside try-with-resources?
  9. Q9. What does this print? (code)
  10. Q10. What is the difference between Files.list(dir) and Files.walk(dir)?