Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-804
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-804.html
Java SE 7 Programmer II
Question No: 61
Given the following code fragment:
-
p1 = paths.get(quot;report.txtquot;);
-
p2 = paths.get(quot;companyquot;);
-
/ / 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?
-
Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
-
Files.move(p1, p2, StandardCopyOption.REPLACE_Existing, LinkOption.NOFOLLOW_LINKS);
-
Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS);
-
Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.copy_ATTRIBUTES,
StandrardCopyOp)
-
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.
Question No: 62
Given the code fragment:
What is the result when the result.txt file already exists in c:\student?
-
The program replaces the file contents and the file#39;s attributes and prints Equal.
-
The program replaces the file contents as well as the file attributes and prints Not equal.
-
An UnsupportedOperationException is thrown at runtime.
-
The program replaces only the file attributes and prints Not equal.
Answer: B Explanation:
Assuming there is a file D:\\faculty\\report.txt then this file will be copied and will be
replacing C:\\student\\report.txt.
Question No: 63
An application is waiting for notification of changes to a tmp directory using the following code statements:
Path dir = Paths.get(quot;tmpquot;)
WatchKey key = dir.register (watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY) ;
In the tmp directory, the user renames the file testA to testB, Which statement is true?
-
The events received and the order of events are consistent across all platforms.
-
The events received and the order of events are consistent across all Microsoft Windows versions.
-
The events received and the order of events are consistent across all UNIX platforms.
-
The events received and the order of events are platform dependent.
Answer: A Explanation:
Most file system implementations have native support for file change notification. The WatchService API takesadvantage of this support where available.
However, when a file system does not support this mechanism, the WatchService will poll the file system,waiting for events.
Note:
WatchKey : When a Watchable entity is registered with a WatchService a key which is a WatchKey isgenerated. Initially the key is in ready state waiting to be notified of any events on the Watchable entity. Oncean event occurs the key goes into signaled state and allows to access the events using its pollEvents method.
After processing the poll events the key has to be reset by invoking its reset method. Reference: The Java Tutorials,Watching a Directory for Changes
Question No: 64
Given:
What is the result?
-
doc
-
index.html
-
an IllegalArgumentException is thrown at runtime.
-
An InvalidPthException is thrown at runtime.
-
Compilation fails.
Answer: B Explanation:
p.getName(int location) = returns path#39; name element by index/location (starts with 0) Example:
path = quot;project//doc//index.htmlquot; p.getName(0) = project p.getName(1) = doc
p.getName(2) = index.html
Question No: 65
Given the code fragment:
What is the result?
-
getName (0): C:\
subpath (0, 2): C:\education\report.txt
-
getName(0): C:\ subpth(0, 2): C:\education
-
getName(0): education subpath (0, 2): education\institute
-
getName(0): education
subpath(0, 2): education\institute\student
-
getName(0): report.txt subpath(0, 2): insritute\student
Answer: C Explanation: Example:
Path path = Paths.get(quot;C:\\home\\joe\\fooquot;); getName(0)
-gt; home subpath(0,2)
Reference: The Java Tutorial, Path Operations
Question No: 66
ITEM Table
-
ID, INTEGER: PK
-
DESCRIP, VARCHAR(100)
-
PRICE, REAL
-
QUALITY, INTEGER
And given the code fragment (assuming that the SQL query is valid):
What is the result of compiling and executing this code?
-
An exception is thrown at runtime
-
Compile fails
-
The code prints Error
-
The code prints information about Item 110
Answer: C Explanation: Tricky:
Compiles successfully ! Not B !
D is correct, if Column Quantity instead of Quality
Table Item Column Quality — System.out.println(quot;Quantity: quot; rs.getInt(quot;Quantityquot;)); wenn jedoch so gewollt: die Zeile gibt Error aus (die anderen funktionieren) !!!
The connection conn is not defined. The code will not compile.
Question No: 67
Which code fragment demonstrates the proper way to handle JDBC resources?
-
try {
ResultSet rs = stmt.executeQuery (query); statement stmt = con.createStatement(); while (rs.next()) (/* . . . */)
} catch (SQLException e) {}
-
try {
Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery (query); while (rs.next()) (/* . . . */)
} catch (SQLException e) {}
-
try {
Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery (query); while (rs.next()) (/* . . . */)
} finally { rs.close();
stmt.close();
}
-
try {
ResultSet rs = stmt.executeQuery (query); Statement stmt = con.createStatement(); while (rs.next()) (/* . . . */)
} finally { rs.close();
stmt.close();
}
Answer: C
Question No: 68
Given the code fragment:
What is the result of the employees table has no records before the code executed?
-
1 Sam
-
4 Jack
-
3 John 4 Jack
-
1 Sam 3 John
4 Jack
Answer: C Explanation:
AutoCommit is set to false. The two following statements will be within the same transaction.
stmt.executeUpdate(quot;insert into employees values(1,#39;Sam#39;)quot;); stmt.executeUpdate(quot;insert into employees values(2,#39;Jane#39;)quot;);
These two statements are rolled-back through (the savepoint is ignored! the savepoint must be specified (e.g.
conn.rollback(save1); ) in the rollback if you want to rollback to the savepoint): conn.rollback() ;
The next two insert statements are executed fine. Their result will be in the output.
Question No: 69
Given the code fragment:
Assume that the SQL queries return records. What is the result of compiling and executing this code fragment?
-
The program prints employee IDs
-
The program prints customer IDs
-
The program prints Error
-
Compilation fails on line ***
Answer: C Explanation:
!!! The given Code prints Error – the second query clears the ResultSet !? ErrorMessage: Operation notallowed after ResultSet closed
It would print A, if second Query i set to rs = stmt.executeQuery(quot;SELECT ID FROM Customerquot;); // Line ***
It would print B, if Line *** is missing. //
The program compiles and runs fine. Both executeQuery statements will run. The first executeQuery statement
(ResultSet rs = stmt.executeQuery(query);) will set the rs Resultset. It will be used in the while loop. EmployIDswill be printed.
Note:
Executes the given SQL statement, which returns a single ResultSet object. Parameters:sql – an SQL statement to be sent to the database, typically a static SQL SELECT statement Returns:a ResultSet object that contains the data produced by the given query; never null
Question No: 70
Which two actions can be used in registering a JDBC 3.0 driver?
-
Add the driver class to the META-INF/services folder of the JAR file.
-
Set the driver class name by using the jdbc.drivers system property.
-
Include the JDBC driver class in a jdbcproperties file.
-
Use the java.lang.class.forName method to load the driver class.
-
Use the DriverManager.getDriver method to load the driver class.
Answer: A,D Explanation:
A: if your JDBC Driver is NOT JDBC 4-compliant then we can update the driver using quot;jarquot;- utility by adding the
quot;META-INF /services/java.sql.Driverquot; inside it. as following:
D:Dynamic loading of Java classes at runtime provides tremendous flexibility in the development of enterprisesystems. It provides for the basis of quot;application serversquot;, and allows even simpler, lighter-weight systems toaccomplish some of the same ends. Within Java, dynamic-loading is typically achieved by calling the forNamemethod on the class java.lang.ClassAn example provided by the standard Java SE API is the ServiceLoader. Amongothers, the JDBC 4.0compatible drivers implement this. This way just dropping the JDBC driver JAR file folder will automatically loadthe driver class during Java application#39;s startup/initialization without the need for any manual Class.forName(quot;com.example.Driverquot;) line in your code.
100% Ensurepass Free Download!
–Download Free Demo:1z0-804 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-804 Dumps
EnsurePass | ExamCollection | Testking | |
---|---|---|---|
Lowest Price Guarantee | Yes | No | No |
Up-to-Dated | Yes | No | No |
Real Questions | Yes | No | No |
Explanation | Yes | No | No |
PDF VCE | Yes | No | No |
Free VCE Simulator | Yes | No | No |
Instant Download | Yes | No | No |
100-105 Dumps VCE PDF
200-105 Dumps VCE PDF
300-101 Dumps VCE PDF
300-115 Dumps VCE PDF
300-135 Dumps VCE PDF
300-320 Dumps VCE PDF
400-101 Dumps VCE PDF
640-911 Dumps VCE PDF
640-916 Dumps VCE PDF
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF
220-901 Dumps VCE PDF
220-902 Dumps VCE PDF
N10-006 Dumps VCE PDF
SY0-401 Dumps VCE PDF