About Question enthuware.ocpjp.v8.2.1552 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
mrmuiz
Posts: 49
Joined: Mon Jul 27, 2015 4:34 am
Contact:

About Question enthuware.ocpjp.v8.2.1552 :

Post by mrmuiz »

I'm working on Java 1.8.0_45.

Code: Select all

Files.newInputStream(Path path, OpenOption... options)
invokes

Code: Select all

FileSystemProvider.newInputStream(Path path, OpenOption... options)
where you can find

Code: Select all

            for (OpenOption opt: options) {
                // All OpenOption values except for APPEND and WRITE are allowed
                if (opt == StandardOpenOption.APPEND ||
                    opt == StandardOpenOption.WRITE)
                    throw new UnsupportedOperationException("'" + opt + "' not allowed");
            }
In fact, all the five options compile in my jre/os. Anyway, being there hardcoded in the class, I think it can be considered a general rule in case of reading.

javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

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

Post by javalass »

Regarding option 4, I get

Code: Select all

UnsupportedOperationException: 'APPEND' not allowed
whether the file already exists or not.

javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

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

Post by javalass »

And option 5 executes fine if the file exists. I'm on Windows.

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

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

Post by admin »

Fixed.
thank you for your feedback!
Paul.

Russtam
Posts: 9
Joined: Fri Dec 04, 2015 11:27 am
Contact:

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

Post by Russtam »

We have correct answer
new OpenOption[]{StandardOpenOption.READ, StandardOpenOption.DELETE_ON_CLOSE}
and that explanation:
Thus, READ and TRUNCATE_EXISTING (or WRITE, APPEND, or DELETE_ON_CLOSE) cannot go together.
one excludes other

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

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

Post by admin »

Unfortunately, it works on Java 8 but does not work on Java 7. So the option is marked as correct for Java 8 version and wrong for Java 7.
The explanation has now been updated accordingly.

thank you!
Paul.

javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

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

Post by javalass »

That explains! Thanks for checking.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests