Exambible 1Z0-804 Questions are updated and all 1Z0-804 answers are verified by experts. Once you have completely prepared with our 1Z0-804 exam prep kits you will be ready for the real 1Z0-804 exam without a problem. We have Latest Oracle 1Z0-804 dumps study guide. PASSED 1Z0-804 First attempt! Here What I Did.
Q9. Which code fragment demonstrates the proper way to handle JDBC resources?
A. try {
ResultSet rs = stmt.executeQuery (query);
statement stmt = con.createStatement();
while (rs.next()) (/* . . . */)
} catch (SQLException e) {}
B. try {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery (query);
while (rs.next()) (/* . . . */)
} catch (SQLException e) {}
C. try {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery (query);
while (rs.next()) (/* . . . */)
} finally {
rs.close();
stmt.close();
}
D. try {
ResultSet rs = stmt.executeQuery (query);
Statement stmt = con.createStatement();
while (rs.next()) (/* . . . */)
} finally {
rs.close();
stmt.close();
}
Answer: C
Q10. Given the incomplete pseudo-code for a fork/join framework application:
And given the missing methods: Process, submit, and splitInHalf Which three insertions properly complete the pseudo-code?
A. Insert submit at line X.
B. Insert splitInHalf at line X.
C. Insert process at line X.
D. Insert process at line Y.
E. Insert splitInHalf at line Y.
F. Insert process at line Z.
G. Insert submit at line Z.
Answer: C,E,G
Explanation:
C: If data is small enough then process it. Line X
E: If data is not small enough then split it half. Line Y
G: After the data has been split (line Y) then recursively submit the splitted data (Line z).
Q11. Given the following code fragment:
10.
p1 = paths.get("report.txt");
11.
p2 = paths.get("company");
12.
/ / insert code here
Which code fragment, when inserted independently at line 12, move the report.txt file to the company directory,at the same level, replacing the file if it already exists?
A. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.ATOMIC_MOVE);
B. Files.move(p1, p2, StandardCopyOption.REPLACE_Existing,
LinkOption.NOFOLLOW_LINKS);
C. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING,
LinkOption.NOFOLLOW_LINKS);
D. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.copy_ATTRIBUTES,
StandrardCopyOp)
E. Files.move (p1, p2, StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.copy_ATTRIBUTES,
LinkOption.NOF)
Answer: A,C
Explanation:
Moving a file is equally as straight forward move(Path source, Path target, CopyOption... options); The available StandardCopyOptions enums available are: StandardCopyOption.REPLACE_EXISTING StandardCopyOption.ATOMIC_MOVE If Files.move is called with StandardCopyOption.COPY_ATTRIBUTES an UnsupportedOperationException isthrown.
Q12. Given:
import java.util.concurrent.atomic.AtomicInteger;
public class AtomicCounter {
private AtomicInteger c = new AtomicInteger(0);
public void increment() {
// insert code here
}
}
Which line of code, inserted inside the increment () method, will increment the value of c?
A. c.addAndGet();
B. c++;
C. c = c+1;
D. c.getAndIncrement ();
Answer: D
Explanation: getAndIncrement
public final int getAndIncrement()
Atomically increment by one the current value.
Reference:java.util.concurrent.atomic
Q13. Which two are valid initialization statements?
A. Map<String, String> m = new SortedMap<String, String>();
B. Collection m = new TreeMap<Object, Object>();
C. HashMap<Object, Object> m = new SortedMap<Object, Object>();
D. SortedMap<Object, Object> m = new TreeMap<Object, Object> ();
E. Hashtable m= new HashMap();
F. Map<List, ArrayList> m = new Hashtable<List, ArrayList>();
Answer: D,F
Q14. Given the code fragment:
And a DOS-based file system:
Which option, containing statement(s), inserted at line 3, creates the file and sets its attributes to hidden andread-only?
A. DOSFileAttributes attrs = Files.setAttribute(file,"dos:hidden","dos: readonly") Files.createFile(file, attrs)
B. Files.craeteFile(file); Files.setAttribute(file,"dos:hidden","dos:readonly");
C. Files.createFile(file,"dos:hidden","dos:readonly");
D. Files.createFile(file); Files.setAttribute(file,"dos:hidden", true); Files.setAttribute(file,"dos:readonly", true);
Answer: D
Explanation:
You can set a DOS attribute using the setAttribute(Path, String, Object, LinkOption...)
method, as
follows:
Path file = ...;
Files.setAttribute(file, "dos:hidden", true);
Note:
setAttribute
public static Path setAttribute(Path path,
String attribute,
Object value,
LinkOption... options)
throws IOException
Sets the value of a file attribute.
Reference:Interface DosFileAttribute
Q15. Given: What is the result?
A. tolting cantering tolting
B. cantering cantering cantering
C. compilation fails
D. an exception is thrown at runtime
Answer: C
Explanation:
Compiler says: Cannot reduce the visibility of the inherited method from Rideable. müssen
PUBLIC sein
public String ride() { return "cantering "; }
public String ride() { return "tolting "; }
if this is given then the result would be:
A : tolting cantering tolting
Q16. Given the directory structure that contains three directories: company, Salesdat, and Finance:
Company
-Salesdat
* Target.dat
-Finance
*
Salary.dat
*
Annual.dat
And the code fragment: If Company is the current directory, what is the result?
A. Prints only Annual.dat
B. Prints only Salesdat, Annual.dat
C. Prints only Annual.dat, Salary.dat, Target.dat
D. Prints at least Salesdat, Annual.dat, Salary.dat, Target.dat
Answer: A
Explanation:
IF !! return FileVisitResult.CONTINUE;
The pattern *dat will match the directory name Salesdat and it will also match the file
Annual.dat.
It will not be matched to Target.dat which is in a subdirectory.