About Question com.enthuware.ets.scjp.v6.2.135 :

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

Moderator: admin

Post Reply
ETS User

About Question com.enthuware.ets.scjp.v6.2.135 :

Post by ETS User »

Answer "You can create files in any directory using File class's API." is misleading because on any platform there are places that are system protected or there are other permissions that will not allow to create new file/directory (in example: home directory of another user).

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

Re: About Question com.enthuware.ets.scjp.v6.2.135 :

Post by admin »

What you say is true but the API itself poses no restrictions. For example, you can't create a file if the disk is full either but that is not what the statement implies.

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

kannattaa
Posts: 4
Joined: Thu Jul 03, 2014 5:11 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.135 :

Post by kannattaa »

Option
Once created there is no way to change the file or directory that the File object represents.
should be matched.

This code changes the file that the File object represents:

Code: Select all

        File file1 = new File("file1.txt");
        File file2 = new File("file2.txt");
        File tempFile = new File("temp_file.txt");
        file1.renameTo(tempFile);
        file2.renameTo(file1);
        file1.delete();
Note, that "the file" term is used, not "the path to file".

Aditya553
Posts: 15
Joined: Sun Aug 06, 2017 2:37 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.135 :

Post by Aditya553 »

Please explain why option 4 is correct?
explanation given -Instances of the File class are immutable; that is, once created, the abstract pathname represented by a File object will never change

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

Re: About Question com.enthuware.ets.scjp.v6.2.135 :

Post by admin »

Because as the explanation says, you can't change the File object after creation. There are no setter methods or public fields in this class. You have to create a new File object if you want to represent a different file.
If you like our products and services, please help us by posting your review here.

alfredo.zuloaga
Posts: 10
Joined: Fri Nov 18, 2016 5:48 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.135 :

Post by alfredo.zuloaga »

why this is not consider as transverse ?
java.io.File a = new File("/");
Arrays.stream(a.list()).limit(10).forEach(System.out::println);

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

Re: About Question com.enthuware.ets.scjp.v6.2.135 :

Post by admin »

You are right. This question is not good. It is too vague and should be removed.
thank you your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 42 guests