Page 1 of 1

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

Posted: Sun Jun 23, 2013 8:14 am
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

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

Posted: Sun Jun 23, 2013 11:18 am
by admin
No, because the given path (i.e. the path object on which resolve is called) is not an absolute path.

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

Posted: Sun Jun 23, 2013 1:07 pm
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.

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

Posted: Sun Jun 23, 2013 1:31 pm
by admin
That's my interpretation. For an absolutely sure answer, you will need to get a response by Oracle :)
-Paul.

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

Posted: Fri Nov 07, 2014 10:50 am
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

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

Posted: Sun Nov 09, 2014 10:38 pm
by admin
No, there are no updates.

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

Posted: Mon Apr 27, 2015 6:40 am
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. "

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

Posted: Mon Apr 27, 2015 7:25 am
by admin
\ is for windows. For *nix (and mac), you have to use /.

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

Posted: Tue Apr 28, 2015 4:27 am
by itsriaz
Okay thanks...