-
Notifications
You must be signed in to change notification settings - Fork 90
/
ch24a.html
80 lines (50 loc) · 3.16 KB
/
ch24a.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Study guide for the Oracle Certified Professional, Java SE 8 Programmer Exam ">
<title>Java 8 Programmer II Study Guide: Exam 1Z0-809</title>
<link href="css/code.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="js/common-sections.js"></script>
</head>
<body>
<div class="header">
<div class="title-container">
<div class="chapter-title">
<h1><i class="chapter">Chapter TWENTY-FOUR</i><br />
NIO.2</h1>
<p><br /></p>
<h3 style="text-align: center;"><i>Exam Objectives</i></h3>
<p style="text-align: center;"><i>Use Path interface to operate on file and directory paths.<br /></i><i>Use Files class to check, read, delete, copy, move, manage metadata of a file or directory.</i></p>
</div>
</div>
</div>
<div class="container">
<div class="column">
<h2>Answers</h2>
<p><b>1. The correct answer is C.</b><br />
<code>Path.resolve()</code> doesn't remove redundancy in paths (that's done with <code>Path.normalize()</code> or <code>Path.toRealPath()</code>), it just combines two paths.</p>
<p><br /></p>
<p><b>2. The correct answer is B.</b><br />
<code>path.getRoot()</code> returns <code>c:\</code><br />
<code>path.getName(0)</code> returns <code>Users</code><br />
<code>path.getName(1)</code> returns <code>mark</code><br />
<code>path.subpath(0,0)</code> throws an exception</p>
<p><code>getName()</code> returns the element parts of a path. The first element is at index zero (the root doesn't count as an element).</p>
<p><br /></p>
<p><b>3. The correct answer is C.</b><br />
<code>CopyOption</code> is an interface implemented by the enumerations <code>StandardCopyOptions</code> (with the values <code>ATOMIC_MOVE</code> (not supported), <code>REPLACE_EXISTING</code>, <code>COPY_ATTRIBUTES</code>) and <code>LinkOption</code> (with the value <code>NOFOLLOW_LINKS</code>).
<p><br /></p>
<p><b>4. The correct answer is D.</b><br />
<code>.</code> means the current directory and <code>..</code> means the parent directory. The method <code>toRealPath()</code> turns the redundant path into <code>C:\temp\file.txt. path.subpath(1,2)</code> give us the element at index <code>1</code>, <code>file.txt</code>.</p>
<p><br /></p>
<p><b>5. The correct answer is D.</b><br /> A file creation time attribute can only be set with <code>BasicFileAttributeView</code>. The right way to do it is with a <code>FileTime</code> instance as shown in Option D.</p>
<p><br /></p>
</div>
</div>
<footer></footer>
</body>
</html>