About Question enthuware.ocpjp.v7.2.1777 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
hesselva
Posts: 1
Joined: Wed Dec 30, 2015 4:10 am
Contact:

About Question enthuware.ocpjp.v7.2.1777 :

Post by hesselva »

The given path in this question is a path on Windows:

Code: Select all

Path path = Paths.get("c:\\temp\\test.txt");
Shouldn't every use of PosixFileAttributeView then generate a RunTimeException since this is not supported on Windows?

admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by admin »

Yes, that is why the question contains a statement that asks you to assume that the file system on which the program is run does support this attribute.

It is possible to implement a file system that supports PosixFileAttributeView and also uses windows like paths. The program will run without any issues on it.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

StShadow
Posts: 3
Joined: Tue Jan 19, 2016 4:55 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by StShadow »

Well, the assumption, that

Code: Select all

"c:\\temp\\test.txt"
is file from Windows, is wrong in general case.

You could have file on Linix named "c:\\temp\\test.txt"

sumanenthu
Posts: 23
Joined: Sun Feb 21, 2016 10:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by sumanenthu »

In mala gupta book for OCP 7 in page 543 section 8.3.7 it is written that -
"To read or update the owner of a file or directory you can use
the AclFileAttributeView, FileOwnerAttributeView, and PosixFile-
Attribute interfaces." Is that wrong?

admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by admin »

I can't really comment on that without knowing the context but did you try asking the author?
Paul.
If you like our products and services, please help us by posting your review here.

sumanenthu
Posts: 23
Joined: Sun Feb 21, 2016 10:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by sumanenthu »

admin wrote:I can't really comment on that without knowing the context but did you try asking the author?
Paul.
No I didn't. While doing the enthuware mock exams, I found some conflicting memories as I read that book. And one more thing is that this was printed as 'exam tip'. So its straightforward, doesn't require a context. Would you post your independent opinion on this?

admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by admin »

The get/setOwner are declared in FileOwnerAttributeView interface. This interface is extended by AclFileAttributeView and PosixFileAttributeView, and you can use those as well. So yes, the statement in the book looks correct.

I have updated the explanation of this question to include this fact.

-Paul.
If you like our products and services, please help us by posting your review here.

jbilkes
Posts: 21
Joined: Tue Sep 09, 2014 3:28 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by jbilkes »

strangely enough i suspect enthuware being wrong here.
Let me explain:

In the explanation it is said that "The name of the method to get the owner of a File is owner and not getOwner. Note that this method returns an instance of java.nio.file.attributeUserPrincipal."

looking into https://docs.oracle.com/javase/7/docs/a ... Files.html it becomes clear that getOwner is the right method. Moreover, it returns not a attributeUserPrincipal (weird classname anyhow being not capitalized) but a UserPrincipal

do i miss something??

admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1777 :

Post by admin »

This option is trying to apply the getOwner method on attrs, whose type is PosixFileAttributes. The explanation that you've quoted is associated with this option and is correct. To get the owner using PosixFileAttributes, the correct method name is owner() and not getOwner(). It returns java.nio.file.attribute.UserPrincipal. (The dot between attribute and UserPrincipal is missing.)
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests