nerdexam
Oracle

1Z0-819 · Question #69

Given public class Main { public static void main (String[] args) { Path path = Paths.get("/u01/work/filestore.txt"); boolean test = Files.deleteIfExists(path); if (test) System.out.println("path "…

The correct answer is B. path is not deleted. See the full explanation below for the reasoning.

Question

Given public class Main { public static void main (String[] args) { Path path = Paths.get("/u01/work/filestore.txt"); boolean test = Files.deleteIfExists(path); if (test) System.out.println("path " + "is deleted."); else System.out.println("path " + "is not deleted."); } catch (IOException e) { System.out.println("Exception"); } } Assume the file on path does not exist. What is the result?

Options

  • AThe compilation fails.
  • Bpath is not deleted.
  • CException
  • Dpath /filestore.txt is deleted.

How the community answered

(47 responses)
  • A
    13% (6)
  • B
    79% (37)
  • C
    6% (3)
  • D
    2% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice