Oracle
1Z0-805 · Question #32
Given the code fragment: public static void main(String[] args) { Path file = Paths.get("D:\\company\\report.txt"); Oracle 1Z0-805 Exam try (SeekableByteChannel sbc = Files.newByteChannel(file,new…
The correct answer is C. The contents of the file remain unchanged. The truncate line will not change the file since the file size is less than 30.
Java I/O Fundamentals
Question
Given the code fragment:
public static void main(String[] args) { Path file = Paths.get("D:\company\report.txt"); Oracle 1Z0-805 Exam try (SeekableByteChannel sbc = Files.newByteChannel(file,new OpenOption[] What is the result if the report.txt file contains Welcome to the world of Java?
Options
- AThe file contains the first five characters.
- BThe file contains the first four characters.
- CThe contents of the file remain unchanged.
- DA NonWritableChannelException is thrown at runtime.
How the community answered
(50 responses)- A6% (3)
- B14% (7)
- C78% (39)
- D2% (1)
Explanation
The truncate line will not change the file since the file size is less than 30.
Topics
#SeekableByteChannel#OpenOption#NIO.2#file channels
Community Discussion
No community discussion yet for this question.