AllRounder.ai
Chapters in this course

Enrol to start learning

Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.

Enrol free

21.2.5. Path, Paths, and Files (Java 7+)

  • This section

    Practice test

    11 questions on this section. Wrong answers show you what to read again.

    Sign up to take it
  • Whole chapter

    Revision test

    Mixed questions from across the chapter. Your answers get marked.

    Sign up to take it
  • Quick

    Flashcard drill

    3 cards from this lesson. Good the night before a test.

Try these first

  1. 1.

    What class is used to represent file paths in the java.nio.file package?

    Hint

    This class is not just a string; it has methods to handle paths.

  2. 2.

    How do you obtain a Path object from a string?

    Hint

    It's a static method from the utility class.

  3. 3.

    Which class is NOT part of the java.nio.file package?

    • Path
    • File
    • Files
    Hint

    Think about the organization of these classes in packages.

  4. 4.

    The Paths class is a utility to create Path instances.

    • True
    • False
    Hint

    Consider what utility classes generally provide.

  5. 5.

    Write a complete Java program to read a file, count the number of lines, and print them to the console, handling any exceptions that may occur.

    Hint

    Don't forget to add exception handling.

  6. 6.

    Modify the previous program to create a new file and write the contents of the original file into it, combining them into one.

    Hint

    Ensure the target file is created without overwriting existing files.

Exercises

Total Questions

2

Estimated Time

4 min

Passing Score

70%

Instructions

  • Read each question carefully
  • You can use hints if you need help
  • Complete all questions before submitting

4 more questions available

Enrol free

Quiz

Total Questions

2

Estimated Time

4 min

Passing Score

70%

Instructions

  • Read each question carefully
  • You can use hints if you need help
  • Complete all questions before submitting

1 more question available

Enrol free

Challenge Problems

Total Questions

2

Estimated Time

4 min

Passing Score

70%

Instructions

  • Read each question carefully
  • You can use hints if you need help
  • Complete all questions before submitting