About Question enthuware.ocpjp.v8.2.1599 :

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

Moderator: admin

Post Reply
johnny_pl
Posts: 1
Joined: Tue Oct 11, 2016 2:59 pm
Contact:

About Question enthuware.ocpjp.v8.2.1599 :

Post by johnny_pl »

In this question, we have:

Code: Select all

        Path p1 = Paths.get("photos\\goa");
        Path p2 = Paths.get("\\index.html");
        Path p3 = p1.relativize(p2);
        System.out.println(p3);
When I'm trying this code out on my Linux machine from IntelliJ, I get the following result:

Code: Select all

../\index.html
However, you mark the answer "java.lang.IllegalArgumentException will be thrown" as the correct one with the explanation "Note that if one path has a root (for example, if a path starts with a // or c:) and the other does not, relativize cannot work and it will throw an IllegalArgumentException."

From my point of view, the path "\\index.html" does not contain a root element. Only if I change this path to "/index.html" than I get this Exception.

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

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

Post by admin »

The exam may contain code with paths in *nix or windows format. You will need to recognize that paths containing forward slash are *nix paths while paths containing \\ are windows paths and select the answer based on that platform. In this case, for example, you should assume that the code is running on windows and not on *nix.

HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests