Java Files  «Prev  Next»

Quiz

1. Which one of the following filenames is most likely to work correctly across Windows, macOS, and Linux?
Please select the best answer.
  A. list_of_compatibility_issues_for_software_projects_2026.txt
  B. list:compatibility_issues
  C. compatibility_issues
  D. compatibility issues list

2. On which platforms does the Java inner class filename FileViewer2$EncodingListener.class cause potential problems?
Please select the best answer.
  A. Windows NTFS
  B. macOS APFS
  C. Linux ext4
  D. Cloud storage platforms with restricted object key naming

3. If the current directory is C:\java\demo on Windows, what absolute path does the relative path ..\src\HelloWorld.java refer to?
Please select the best answer.
  A. C:\java\demo\src\HelloWorld.java
  B. C:\src\HelloWorld.java
  C. C:\java\HelloWorld.java
  D. C:\java\src\HelloWorld.java

4. In Java NIO.2, which class is the preferred way to represent a file or directory path in a platform-independent manner?
Please select the best answer.
  A. java.io.File
  B. java.nio.file.Path
  C. java.lang.String
  D. java.io.FileDescriptor

5. What is one key difference between a file and a stream in Java?
Please select the best answer.
  A. It is possible to jump around in a stream but not in a file.
  B. It is possible to jump around in a file but not in a stream.
  C. There is no difference — a file is a type of stream.
  D. Files are always larger than streams.

6. Which Java NIO.2 method is the recommended way to read all bytes from a file into memory in modern Java?
Please select the best answer.
  A. Files.readAllBytes(Path)
  B. new FileInputStream(file).read()
  C. File.getBytes()
  D. InputStream.readAll()

7. Which method on java.nio.file.Path converts a relative path to an absolute path using the current working directory?
Please select the best answer.
  A. Path.normalize()
  B. Path.resolve(other)
  C. Path.toAbsolutePath()
  D. Path.toRealPath()