About Question enthuware.ocpjp.v7.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
hamada.yamasaki
Posts: 17
Joined: Fri Oct 11, 2013 10:31 am
Contact:

About Question enthuware.ocpjp.v7.2.1599 :

Post by hamada.yamasaki »

How come
Paths.get("\\index.html");
has root. The root under linux is / and for windows is c:\

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

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

Post by admin »

It considers a path starting with \\ as root as well. Although they haven't specified an exact definition of a root anywhere.

You may want to try it out.
-Paul.

razvan.luca
Posts: 1
Joined: Sat Jun 20, 2015 11:42 am
Contact:

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

Post by razvan.luca »

I'm don't understand why Explanation is saying that "if a path starts with a // or c:" has a root, but example is with "\\"
Paths.get("\\index.html");

It doesn't matter if it's starting with "\\" or "//", that's always a root?

Thanks

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

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

Post by admin »

Well, On *nix systems, path separator is /, a path starting with \ is not root.

Jimothy
Posts: 2
Joined: Sat Oct 31, 2015 4:19 am
Contact:

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

Post by Jimothy »

Prints the following on my linux box:
../\index.html

zhengye1
Posts: 17
Joined: Wed Jan 07, 2015 12:06 am
Contact:

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

Post by zhengye1 »

To run the code in linux, you need to create the path object like this

Code: Select all

        Path p1 = Paths.get("photos/goa"); 
        Path p2 = Paths.get("/index.html"); 
because the root in Linux is "/"...

I want to know in the real exam, do they specified which OS they using? If not , it seems like ambiguous about the separator...

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

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

Post by admin »

In the exam, you can assume that if the separater is /, then the code is for linux and if it is \\, then the code is for windows.

HTH,
Paul.

jagoneye
Posts: 97
Joined: Wed Dec 28, 2016 9:00 am
Contact:

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

Post by jagoneye »

So on nix systems I am assuming "/" has to escaped to "//" hence the code in question also causes error? Am I right?

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

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

Post by admin »

No, on a *nix based system, you do not need to escape /.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests