What is the result of executing the following code? (Choose all that apply.)
1: Path path = Paths.get("data.txt"); 2: BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class); 3: if(attributes.size()>0 && attributes.creationTime().toMillis()>0) { 4: attributes.setTimes(null,null,null); 5: }
D.
The setTimes()
method is available only on BasicFileAttributeView, not the read only BasicFileAttributes class, so line 4 will not compile and D is correct.
You need to retrieve an instance of the view class to update the data.
The rest of the lines compile without issue and only D is correct.