Oracle Upgrade to Java SE 7 Programmer - 1Z1-805 Exam Practice Test
Given:
public class DAOManager {
public AccountDAO getAccountDAO() {
return new AccountJDBCDAO();
}
}
Which design pattern best describes the class?
public class DAOManager {
public AccountDAO getAccountDAO() {
return new AccountJDBCDAO();
}
}
Which design pattern best describes the class?
Correct Answer: C
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
Which two statements are true?
Correct Answer: B,E
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
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: A
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
Given:

What two changes should you make to apply the DAO pattern to this class?

What two changes should you make to apply the DAO pattern to this class?
Correct Answer: B,C
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
The default file system includes a logFiles directory that contains the following files:
log - Jan2009
log_01_2010
log_Feb2010
log_Feb2011
log-sum-2012
How many files the matcher in this fragment match?
PathMatcher matcher = FileSystems.getDefault ().getPathMatcher ("glob:???_*1");
log - Jan2009
log_01_2010
log_Feb2010
log_Feb2011
log-sum-2012
How many files the matcher in this fragment match?
PathMatcher matcher = FileSystems.getDefault ().getPathMatcher ("glob:???_*1");
Correct Answer: A
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
Which two fragments can be combined into a statement that returns an ExecuteService instance?
Correct Answer: E,G
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
Given the code fragment:
Path path1 = Paths.get("D:\\sales\\.\\quarterly\\..\\report");
path1 = path1.normalize();
Path path2 = path1.relativize(Paths.get("d:\\empdetails.dat"));
path2 = path2.resolve(path1);
System.out.println(path1);
System.out.println(path2);
}
What is the result?
Path path1 = Paths.get("D:\\sales\\.\\quarterly\\..\\report");
path1 = path1.normalize();
Path path2 = path1.relativize(Paths.get("d:\\empdetails.dat"));
path2 = path2.resolve(path1);
System.out.println(path1);
System.out.println(path2);
}
What is the result?
Correct Answer: A
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
You are using a database from XY/Data. What is a prerequisite for connecting to the database using a JDBC 4.0 driver from XY/Data?
Correct Answer: C
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).
Given:
import java.io.*;
public class SampleClass {
public static void main(String[] args) throws IOException {
try {
String dirName = args[0];
File dir = new File(dirName);
File.createTempFile("temp", "log", dir);
} catch (NullPointerException | IOException e) {
e = new IOException("Error while creating temp file");
throw e;
}
}
}
What is the result?
import java.io.*;
public class SampleClass {
public static void main(String[] args) throws IOException {
try {
String dirName = args[0];
File dir = new File(dirName);
File.createTempFile("temp", "log", dir);
} catch (NullPointerException | IOException e) {
e = new IOException("Error while creating temp file");
throw e;
}
}
}
What is the result?
Correct Answer: A
Vote an answer
Explanation: Only visible for Fast2test members. You can sign-up / login (it's free).