About Question enthuware.ocpjp.v8.2.1584 :

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

Moderator: admin

nowkarol
Posts: 5
Joined: Sun Aug 05, 2018 5:41 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by nowkarol »

I noticed that (maybe it is file system dependent) having same thing on both sides doesn't result in adding /..
This seem obvious, but it couter intuitive that:

Code: Select all

Path p1 = Paths.get("/personal/.././readme.txt");
Path p2 = Paths.get("/personal/./../index.html");
have different result than

Code: Select all

Path p1 = Paths.get("/personal/.././readme.txt");
Path p2 = Paths.get("/personal/.././index.html");

Mark7777
Posts: 32
Joined: Tue Apr 12, 2016 9:19 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by Mark7777 »

All these questions and answers have my head spinning. Here's my question. First, the code:

Path p1 = Paths.get("c:\\personal\\.\\photos\\..\\readme.txt");
Path p2 = Paths.get("c:\\personal\\index.html");
Path p3 = p1.relativize(p2);

I learned in K & B that the objective is to get from readme.txt to index.html. Do that by counting upward the number of directories from readme.txt. Tell me if I'm wrong, but I'm assuming I stop at \personal\ because that is the directory both paths have in common, and I don't need to count back to the root. So I count up four directories," \\personal\\.\\photos\\..\\" including the single dot (.) which is not removed because we're not normalizing. That gives me ..\..\..\.., the fourth directory being \personal\. So I jump to the \personal\ of p2 and attach \index.html, and now I have ..\..\..\..\index.html. Right? Go up four directories, jump over to p2's \personal\ and attach index.html. And then I can double-check it using your technique.

Am I correct in assuming that in counting up the directory tree I don't need to go to the root c: which both paths have in common? I stop at the first directory they have in common, that being \personal\. And, am I correct in counting the first \\..\\ directory, and the \\.\\ (one dot current directory)?

Thanks in advance.

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

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by admin »

Yes, that is correct. You should try out more examples to confirm.
If you like our products and services, please help us by posting your review here.

BinSlayer
Posts: 10
Joined: Tue Jul 09, 2019 8:33 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by BinSlayer »

While it's fine for OCP 8, this question is also present in OCP 11 Pt 2. That means the correct answer is the 3rd answer and not the 1st. Couldn't you guys update it in OCP 11?

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

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by admin »

You are right. We have gone through all questions involving relativize and have made sure they use the logic used by Java 11 in the OCP 11 Pt 2 question bank (version 1.12).

thank you for your feedback!

PS. We just sent you an email.
If you like our products and services, please help us by posting your review here.

JoesJavaAccount
Posts: 1
Joined: Sun Aug 18, 2019 3:46 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by JoesJavaAccount »

Hi,

I've just downloaded the Java 11 upgrade exam and came across this as well. Am I right in now assuming that the correct answer here should now be "..\\index.html" ? That's the answer I chose but it was marked incorrect, and still says the correct answer should be "..\..\..\..\index.html"
My version is v11.2.1584.

Thank

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

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by admin »

Apparently the change did not propagate to the upgrade question bank. I have verified that it has now been updated there as well in version 1.12.
If you like our products and services, please help us by posting your review here.

marcioggs
Posts: 10
Joined: Sat Aug 31, 2019 3:19 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by marcioggs »

I'm using Java 8 with Oracle's JDK and this is being printed:

Code: Select all

..\index.html

Code: Select all

>java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

Code: Select all

>ver
Microsoft Windows [versão 10.0.17763.678]

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

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by admin »

On Java 8 ( v.1.8.0.21) , it prints ..\..\..\..\index.html
On Java 11,(11.0.2), it prints, ..\index.html
If you like our products and services, please help us by posting your review here.

bvrulez
Posts: 33
Joined: Sat Feb 15, 2020 12:44 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by bvrulez »

As from the explanation "if both paths have a root component" it is dependent of the implementation if a relative path can be constructed. So, this question is a bit out of scope but as I understand it might be on the exam, anyway. Also, after reading through the comments, I suppose some implementation on the base of Java 8 will deliver wrong results if compiled with Java 11 now. But probably, that's normal. Thanks for your work!

Nichar
Posts: 1
Joined: Sat Aug 29, 2020 1:20 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1584 :

Post by Nichar »

This StackOverflow question explains the difference between Java 8 and Java 9 implementations.

https://stackoverflow.com/q/63872767/3764965

For my bad, I tried to run the program on java 11 first :lol:

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests