About Question enthuware.ocpjp.v7.2.1402 :

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

Moderator: admin

Post Reply
pfilaretov
Posts: 35
Joined: Mon Jul 28, 2014 2:05 am
Contact:

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

Post by pfilaretov »

Option 3: "You can create files in any directory using File class's API."
You can create files in any directory if you have rights for that, isn't it?

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

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

Post by admin »

Yes, you will need to assume that such things are in order. Otherwise, there are a lot of dependencies and a question will not be able to list all. For example, if there is free disk space, and if the disk is writable, and if the directory doesn't contain a file by the same name already.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

pfilaretov
Posts: 35
Joined: Mon Jul 28, 2014 2:05 am
Contact:

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

Post by pfilaretov »

I see, thx, Paul

dieterdde
Posts: 19
Joined: Wed May 25, 2016 4:33 am
Contact:

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

Post by dieterdde »

Hello,

option #4:

//assume that test.txt exists, and hmm.txt does not:

File f = new File("test.txt");
Files.move(f.toPath(),new File("hmm.txt").toPath());
System.out.printf("%s - %b", f, Files.exists(Paths.get("hmm.txt")));
--> test.txt - true

In any case, if one would argue that i should restrict my argument only to java.io.File, even then you can use renameTo(), whilst it won't change the original file object (ref var will point to a new file object and the other one will be garbage collected i assume), it will still change the underlying path!

Option #4 does not say anything that we can't change the File object instances, it only talks about changing the underlying, whether that underlying is represented by an instance of Path, File or whatever shouldn't matter.

Cheers,
Dieter

Post Reply

Who is online

Users browsing this forum: No registered users and 213 guests