• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Questions on OCP 1z0-809 exam

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone!

If I run into a question like this on OCP 1z0-809 exam:


p1 here would be considered as relative path(as on Windows) or absolute path(as on Mac/Linux)?

Because the answers to such a question like will be different.

Thanks!
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nick,
Welcome to CodeRanch!

You can assume that if a path begins with /, it is an absolute path for Linux/Mac. (unless they explicitly state otherwise in the question)
 
Nick Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne
Thanks so much for your reply.
So even I'm taking the exam on a Windows-based computer, the paths begin with "/" will be considered as absolute paths?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

By relative paths, are you referring to drive letter differences for Windows? ... meaning C:, D:, E:, etc.


I believe, when the docs discuss absolute and relative paths, the discussion is based on absolute / relative from the root. And it seems to "hand wave" what the root is -- meaning, it seems to not take drive letters into account.

Henry
 
Nick Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry
Thanks for your reply!
When I'm running the following codes on Eclipse Mars.2 on Windows 10:

Path p = Paths.get("/123/456/789.txt");
System.out.println(p.isAbsolute());

The result will be false.
That's why I'm confused.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't know what to tell you, because like I stated, there seems to be some hand waving in the JavaDoc regarding this.  Regardless, on Windows, the code does seems to be related to the drive letter. Putting in a drive letter in your example does return true.


IMHO, I think you should follow Jeanne's advice, and unless otherwise mentioned, you probably should assume Linux.... I would even argue that you probably should assume Solaris due to Java's roots (originated from Sun Microsystems).

Henry
 
Enthuware Software Support
Posts: 4803
52
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The whole point of having the isAbsolute method is to know whether a path is absolute or not. Whether a given path is absolute or not depends on the OS. So you can't really tell by looking at just the path without knowing the OS, technically speaking.
However, the following can be safely assumed for the exam:
1. If a path uses / (forward slash) as a separator, it is a *nix path. Thus, if a a path starts with a /, it is an absolute path.
2. If a path contains \\ (two back slashes) as a separator, it is a windows path. On windows, for a path to be an absolute path, it has to start with a drive letter (such as c:, d:, etc. ).
3. Finally, if a path contains \\ as well as /, well, read the question carefully. There might be additional information that will tell you what it is. Apply common sense and hope for the best We haven't seen anyone getting such paths.

Oh and btw, The OS on which you are taking the test is completely irrelevant.

HTH,
Paul.
 
Nick Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much for the detailed explanation, Paul and Henry.
I will see paths starting with "/" as absolute paths on the OCP exam.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nick,
No code is actually running on the exam. The computer is just a delivery mechanism for questions and answers. It doesn't know if you are on Windows.
 
Nick Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne
I just passed the OCP with score 70% this afternoon. (Yes today is a working Sunday in China...)
I can't Thank you enough for the book you and Mr. Selikoff wrote. Without this magnificent book, I wouldn't even know where to get started with the exam.
I'm really appreciated!
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congrats Nick!
 
Paul Anilprem
Enthuware Software Support
Posts: 4803
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulations!!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic