Oracle Upgrade to Java SE 7 Programmer - 1Z0-805 FREE EXAM DUMPS QUESTIONS & ANSWERS

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?
Correct Answer: E Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given the fragment:
public class CustomerApplication {
public static void main (String [] args) {
CustomerDAO custDao = new CustomerDAOMemoryImp1 ();
// . . . other methods
} }
Which two valid alternatives to line 3 would decouple this application from a specific implementation of customerDAO?
Correct Answer: A,E Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
View the Exhibit:

Given the following code fragment: class Finder extends SimpleFileVisitor<Path> { private final PathMatcher matcher; private static int numMatches = 0;
Finder() {
matcher = FileSystems.getDefault().getPathMatcher("glob:*java");
}
void find(Path file) {
Path Name = file.getFileName();
if (name != null && matcher.matches(name)) {
numMatches++;
}
}
void report()
{
System.out.println("Matched: " + numMatches);
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
find(file);
return CONTINUE;
}
}
public class Visitor {
public static void main(String[] args) throws IOException {
Finder finder = new Finder();
Files.walkFileTree(Paths.get("d:\\Project"), finder);
finder.report();
}
}
What is the result?
Correct Answer: A Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given the following incorrect program:
class MyTask extends RecursiveTask<Integer> {
final int low;
final int high;
static final int THRESHOLD = /* . . . */
MyTask (int low, int high) { this.low = low; this.high = high; }
Integer computeDirectly()/* . . . */
protected void compute() {
if (high - low <= THRESHOLD)
return computeDirectly();
int mid = (low + high) / 2;
invokeAll(new MyTask(low, mid), new MyTask(mid, high));
Which two changes make the program work correctly?
Correct Answer: B,C Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given the code fragment:
dataFormat df;
Which statement defines a new DataFormat object that displays the default date format for the UK Locale?
Correct Answer: E Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Which two statements are true about RowSet subinterfaces?
Correct Answer: A,D Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given the code fragment:
SimpleDateFormat sdf;
Which code fragment displays the two-digit month number?
Correct Answer: A Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
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?
Correct Answer: C Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
What statement is true about thread starvation?
Correct Answer: A Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
0
0
0
10