• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt on question - OCP Objective - 8.0 Java File I/O (NIO.2)

 
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question on a quiz question that I found on the cd (book K&B7).

Given this code:


which compile and run without error in Windows?

The possibilities of choice are:


A - BasicFileAttributes attr = Files.readAttributes(dir, BasicFileAttributes.class);
B - BasicFileAttributes attr = Files.readAttributes(dir, DosFileAttributes.class);
C - DosFileAttributes attr = Files.readAttributes(dir, BasicFileAttributes.class);
D - DosFileAttributes attr = Files.readAttributes(dir, DosFileAttributes.class);
E - BasicFileAttributes attr = new BasicFileAttributes(dir);
F - BasicFileAttributes attr = dir.getBasicFileAttributes();



I can not understand why A and B are incorrect.
The solution gives this explanation:


A and B are incorrect because the archive attribute only exists on the Windows platform. The code fails to compile since archive is not found on BasicFileAttributes.



But I just can not understand the logical link with archive attribute.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the JavaDoc for BasicFileAttributes.html. There is no isArchive() method listed on that page. Therefore the code does not compile.
 
John Lerry
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, thanks for your reply.

I have one more question. what it refers to this statement?

John Lerry wrote:
A and B are incorrect because the archive attribute only exists on the Windows platform.



DosFileAttributes is an interface that works on Windows, but I do not understand because this would be a problem.


 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Lerry wrote:ok, thanks for your reply.

I have one more question. what it refers to this statement?

John Lerry wrote:
A and B are incorrect because the archive attribute only exists on the Windows platform.



DosFileAttributes is an interface that works on Windows, but I do not understand because this would be a problem.



A & B have nothing to do with Windows. They don't mention DosFileAttributes. That's the problem.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic