Oracle Upgrade to Java SE 7 Programmer (1Z1-805) Free Practice Test
Question 1
Which three enum constants are defined in FilevisitResult?
Correct Answer: A,B,E
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 2
Given:
ConcurrentMap<String, String> partList = new ConcurrentHashMap<> (); Which fragment puts a key/value pair in partList without the possibility of overwriting an existing key?
ConcurrentMap<String, String> partList = new ConcurrentHashMap<> (); Which fragment puts a key/value pair in partList without the possibility of overwriting an existing key?
Correct Answer: A
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 3
Given:
private static void copyContents() {
try (
InputStream fis = new FileInputStream("report1.txt");
OutputStream fos = new FileOutputStream("consolidate.txt");
) {
byte[] buf = new byte[8192];
int i;
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
fis.close();
fis = new FileInputStream("report2.txt");
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
}
What is the result?
private static void copyContents() {
try (
InputStream fis = new FileInputStream("report1.txt");
OutputStream fos = new FileOutputStream("consolidate.txt");
) {
byte[] buf = new byte[8192];
int i;
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
fis.close();
fis = new FileInputStream("report2.txt");
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
}
What is the result?
Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 4
Which two statements are true about the walkFileTree method of the files class?
Correct Answer: B,D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 5
Given three resource bundles with these values set for menu1: ( The default resource bundle is
written in US English.)
English US resource Bundle
Menu1 = small
French resource Bundle
Menu1 = petit
Chinese Resource Bundle
Menu = 1
And given the code fragment:
Locale.setDefault (new Locale("es", "ES")); // Set default to Spanish and Spain
loc1 = Locale.getDefault();
ResourceBundle messages = ResourceBundle.getBundle ("messageBundle", loc1);
System.out.println (messages.getString("menu1"));
What is the result?
written in US English.)
English US resource Bundle
Menu1 = small
French resource Bundle
Menu1 = petit
Chinese Resource Bundle
Menu = 1
And given the code fragment:
Locale.setDefault (new Locale("es", "ES")); // Set default to Spanish and Spain
loc1 = Locale.getDefault();
ResourceBundle messages = ResourceBundle.getBundle ("messageBundle", loc1);
System.out.println (messages.getString("menu1"));
What is the result?
Correct Answer: A
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 6
Given the code fragment:
static void addContent () throws Exception {
Path path = Paths.get("D:\\company\\report.txt");
UserPrincipal owner = path.getFileSystem().getUserPrincipalLookupService().lookupPrincipalByName("Bob");
Files.setOwner(path, owner);
// insert code here - Line **
br.write("this is a text message ");
}
System.out.println("success");
}
Assume that the report.txt file exists.
Which try statement, when inserted at line **, enables appending the file content without writing the metadata to the underlying disk?
static void addContent () throws Exception {
Path path = Paths.get("D:\\company\\report.txt");
UserPrincipal owner = path.getFileSystem().getUserPrincipalLookupService().lookupPrincipalByName("Bob");
Files.setOwner(path, owner);
// insert code here - Line **
br.write("this is a text message ");
}
System.out.println("success");
}
Assume that the report.txt file exists.
Which try statement, when inserted at line **, enables appending the file content without writing the metadata to the underlying disk?
Correct Answer: E
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 7
Which two scenarios throw FileSystemNotFoundException when the paths.get(URI) method is invoked?
Correct Answer: B,E
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 8
Which three must be used when using the Java.util.concurrent package to execute a task that returns a result without blocking?
Correct Answer: A,C,D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 9
Which two Capabilities does Java.util.concurcent.BlockingQueue provide to handle operation that cannot be handled immediately?
Correct Answer: A,B
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).