exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 150 discussion

Actual exam question from Oracle's 1z0-819
Question #: 150
Topic #: 1
[All 1z0-819 Questions]

Given the code fragment:



The /scratch/exam/temp.txt file exists. The /scratch/exam/new.txt and /scratch/new.txt files do not exist.

What is the result?

  • A. A copy of /scratch/exam/new.txt exists in the /scratch directory and /scratch/exam/new.txt is deleted.
  • B. The program throws a FileAlreadyExistsException.
  • C. /scratch/exam/new.txt and /scratch/new.txt are deleted.
  • D. The program throws a NoSuchFileException.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
cathDev
3 months, 1 week ago
Selected Answer: B
java.nio.file.FileAlreadyExistsException: \scratch
upvoted 1 times
...
ASPushkin
4 months ago
Selected Answer: A
Files.copy(currentFile, outputFile) created new.txt file Files.copy(outputFile, directory) throws java.nio.file.FileAlreadyExistsException because of existing of the /scratch/ folder
upvoted 1 times
...
d7bb0b2
6 months, 1 week ago
Selected Answer: B
Path directory = Paths.get(pathInit+"/scratch/"); try to create a file with the name scratchh but this exist and is a folder so cannot create and throwN already,..
upvoted 1 times
...
Omnisumem
9 months ago
Selected Answer: B
Tested: B, ... java.nio.file.FileAlreadyExistsException..
upvoted 1 times
...
[Removed]
10 months, 3 weeks ago
Selected Answer: B
I've tried it out and B is correct. If the second statement were absent. The delete would also throw an Exception because the directory is not empty. Correct me if I'm wrong
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago