About Question enthuware.ocpjp.v7.-2-.1608 :

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

Moderator: admin

Post Reply
The_Nick
Posts: 132
Joined: Thu May 16, 2013 9:23 am
Contact:

About Question enthuware.ocpjp.v7.-2-.1608 :

Post by The_Nick »

Should not be the answer "it's system dependent"?
resolve
Path resolve(Path other)
Resolve the given path against this path.
If the other parameter is an absolute path then this method trivially returns other. If other is an empty path then this method trivially returns this path. Otherwise this method considers this path to be a directory and resolves the given path against this path. In the simplest case, the given path does not have a root component, in which case this method joins the given path to this path and returns a resulting path that ends with the given path. Where the given path has a root component then resolution is highly implementation dependent and therefore unspecified.

Parameters:
other - the path to resolve against this path
"If the other parameter is an absolute path then this method trivially returns other." In your example you are not using an absolute path so this is not the case.
The example case is:

"Where the given path has a root component then resolution is highly implementation dependent and therefore unspecified."

If it was an absolute path it would have started with c://.
Therefore the answer should be it's system dependent. Isnt' it?

The_Nick

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

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

Post by admin »

No, because the given path (i.e. the path object on which resolve is called) is not an absolute path.
If you like our products and services, please help us by posting your review here.

The_Nick
Posts: 132
Joined: Thu May 16, 2013 9:23 am
Contact:

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

Post by The_Nick »

Ok so if it's in that way. Why they specify that:
If the other parameter is an absolute path then this method trivially returns other.
Should not be system dependent if the argument passed is an Absolute path.

but they say that if a "root component is present" it's system dependent..

Are you sure that by having a root component and being an absolute path they don't mean different situation?

Just to be clear.. for example in linux "//yellow" might well be an absolute (not real) path.

Thanks in advance.

The_Nick.

Bottom line: I would like to know when it's actually system dependent.

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

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

Post by admin »

That's my interpretation. For an absolutely sure answer, you will need to get a response by Oracle :)
-Paul.
If you like our products and services, please help us by posting your review here.

tanzwud
Posts: 19
Joined: Mon Sep 01, 2014 9:45 pm
Contact:

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

Post by tanzwud »

Hello is there any updates on that question? I'm using Linux Ubuntu and non of this answers close to real answer. If there is no information about system or platform dependency are Windows based systems by default on Java 7 exam ? Many thanks

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

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

Post by admin »

No, there are no updates.
If you like our products and services, please help us by posting your review here.

itsriaz
Posts: 10
Joined: Tue Nov 18, 2014 10:01 am
Contact:

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

Post by itsriaz »

I was just wondering if you could help me with the output. When i run the program on Mac

Code: Select all

Path p1 = Paths.get("\\photos\\vacation"); 
		Path p2 = Paths.get("\\yellowstone");
System.out.println(p1.resolve(p2)+"\n"+p1.relativize(p2));
 
Result is:
\photos\vacation/\yellowstone
../\yellowstone
and for code p2 without \\

Code: Select all

    Path p1 = Paths.get("\\photos\\vacation"); 
		Path p2 = Paths.get("yellowstone"); 
System.out.println(p1.resolve(p2)+"\n"+p1.relativize(p2));
Result is:
\photos\vacation/yellowstone
../yellowstone
while the explanation in the answer says "If the argument doesn't start with a \ and it doesn't start with a root such as c:, the output is the result on appending the argument to the path on which the method is invoked. "

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

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

Post by admin »

\ is for windows. For *nix (and mac), you have to use /.
If you like our products and services, please help us by posting your review here.

itsriaz
Posts: 10
Joined: Tue Nov 18, 2014 10:01 am
Contact:

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

Post by itsriaz »

Okay thanks...

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 43 guests