• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Errata OCP study guide JSE 11 Programmer II, question 10 chapter 9.

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Using APPEND, if the target file already exists, the contents of source file will be append to the end of target file and if the target not exists will be thrown an exception.

Making letter C and E correct.

Img -> https://ibb.co/N7T7Y04
 
Sheriff
Posts: 26773
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you simply asserting that an exception will be thrown, or do you have some evidence for that statement?

(By the way: when you make a post, isn't there an "Attachments" tab at the bottom of the box where you type your post? Using that would be much preferred compared to making readers go to some other site.)
 
Nicholas Barbosa
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Are you simply asserting that an exception will be thrown, or do you have some evidence for that statement?

(By the way: when you make a post, isn't there an "Attachments" tab at the bottom of the box where you type your post? Using that would be much preferred compared to making readers go to some other site.)



Yes!



If "target" not exists, an exception will be thrown. In case you haven't tested the photo code, here is a problem related to APPEND enum value in the stackoverflow.

Stackoverflow->https://stackoverflow.com/questions/30908816/java-nio-file-nosuchfileexception-why-nio-not-creating-file

Excerpt from the stackoverflow response that proves that the letter C is correct and not B, "You're using StandardOpenOption.APPEND, but that won't create a file; it will append to an existing file."
Screenshot-2020-12-30-170624.png
question 10,chapter 9.
question 10,chapter 9.
 
Paul Clapham
Sheriff
Posts: 26773
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the answer you posted goes on to say "The APPEND option creates the file if it does not exist" but that appears to be false. The documentation for APPEND certainly doesn't say that and the Stack Overflow poster was complaining that APPEND didn't create the file too.
 
Marshal
Posts: 74004
332
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please search; I think somebody reported this problem a few weeks ago.
 
Marshal
Posts: 22449
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The official documentation of Files.newBufferedWriter is oddly unclear about what to do in this case.

Fortunately, I've written a few file system implementations myself, and therefore know that implementing a file system does not require implementing any methods for creating a writer. The only writable objects you can create are:
* an OutputStream: Files.newOutputStream
* a SeekableByteChannel: Files.newByteChannel

The documentation for newOutputStream clearly states that APPEND without CREATE should cause an exception to be thrown if the file does not exist. Therefore, answer C is correct, and the answer explanation is incorrect.
 
Saloon Keeper
Posts: 1277
38
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was doing a grand errata roundup this afternoon because I'd missed some that I was on the verge of reporting.

I don't see this one on their errata website, tho I complained about the general topic of modes which carried thru to the review question / mock exam question (same misconception by authors at time of typing it).

Should this be moved to the OCPJP forum?  I agree that the answer accepted as correct is indeed wrong.

EDIT -- NOPE: We are good.  Wrong answer choices always get reported not according to the page that the question is on, but the page number of the appendix at the end of the book containing the answers.
Whenever someone is about to take a chapter review test, it is a good idea to go check the bottom of the errata for their book to make sure that there isn't an erroneous answer accepted as correct instead of the true one.  Despite "knowing" this, I always look solely at the errata for the page ranges the questions are on and forget to look down at the bottom where they describe incorrect answer sets marked as correct, along with any wrong explanations given for the answers (which I would expect to see there).
 
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah. I put the errata on the page the error is on. Which for the answer is the appendix.
 
I once met a man from Nantucket. He had a tiny ad
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic