Examcollection offers free demo for 1Z0-805 exam. "Upgrade to Java SE 7 Programmer", also known as 1Z0-805 exam, is a Oracle Certification. This set of posts, Passing the Oracle 1Z0-805 exam, will help you answer those questions. The 1Z0-805 Questions & Answers covers all the knowledge points of the real exam. 100% real Oracle 1Z0-805 exams and revised by experts!


♥♥ 2017 NEW RECOMMEND ♥♥

Free VCE & PDF File for Oracle 1Z0-805 Real Exam (Full Version!)

★ Pass on Your First TRY ★ 100% Money Back Guarantee ★ Realistic Practice Exam Questions

Free Instant Download NEW 1Z0-805 Exam Dumps (PDF & VCE):
Available on: http://www.surepassexam.com/1Z0-805-exam-dumps.html

Q41. Given the code fragment: 

public static void main(String[] args) { 

Path file = Paths.get("D:\\\\company\\\\report.txt"); 

try (SeekableByteChannel sbc = Files.newByteChannel(file,new OpenOption[] 

sbc.position(5); 

sbc.truncate(30); 

} catch (IOException e) { System.err.printin(“Caught IOException: “ + e.getMessage () } ; } } 

What is the result if the report.txt file contains 

Welcome to the world of Java? 

A. The file contains the first five characters. 

B. The file contains the first four characters. 

C. The contents of the file remain unchanged. 

D. A NonWritableChannelException is thrown at runtime. 

Answer:

Explanation: The truncate line will not change the file since the file size is less than 30. 

Reference: Interface SeekableByteChannel 


Q42. Given the code fragment: String query = "SELECT ID FROM Employee"; \\\\ Line 1 

try (Statement stmt = conn.CreateStatement()) { \\\\ Line 2 

ResultSet rs = stmt.executeQuery(query); \\\\ Line 3 

stmt.executeQuery ("SELECT ID FROM Customer"); \\\\ Line 4 

while (rs.next()) { 

\\\\process the results 

System.out.println ("Employee ID: " + rs.getInt("ID") ); 

} catch (Exception e) { 

system.out.println ("Error"); 

Assume that the SQL queries return records. What is the result of compiling and executing this code fragment? 

A. The program prints employees IDs. 

B. The program prints customer IDs. 

C. The program prints Error. 

D. Compilation fails on line 13. 

Answer:

Explanation: Line 3 sets the resultset rs. rs will contain IDs from the employee table. 

Line 4 does not affect the resultset rs. It just returns a resultset (which is not used). 

Note: 

A ResultSet object is a table of data representing a database result set, which is usually generated by executing a statement that queries the database. 

You access the data in a ResultSet object through a cursor. Note that this cursor is not a database cursor. This cursor is a pointer that points to one row of data in the ResultSet. 

Initially, the cursor is positioned before the first row. The method ResultSet.next moves the cursor to the next row. This method returns false if the cursor is positioned after the last row. This method repeatedly calls the ResultSet.next method with a while loop to iterate through all the data in the ResultSet. 

Reference: The Java Tutorials,Retrieving and Modifying Values from Result Sets 


Q43. Given: 

class Fibonacci extends RecursiveTask<Integer> { 

final int n; 

Fibonacci (int n) { this.n = n } 

Integer compute () { 

if (n <= 1) 

return n; 

Fibonacci f1 = new Fibonacci (n – 1); 

f1.fork; 

Fibonacci f2 = new Fibonacci (n – 2); 

return f2.compute() + f1.join; // Line ** 

Assume that line ** is replaced with: 

return f1.join() + f2.compute(); // Line ** 

What is the likely result? 

A. The program produces the correct result, with similar performance to the original. 

B. The program produces the correct result, with performance degraded to the equivalent of being single-threaded. 

C. The program produces an incorrect result. 

D. The program goes into an infinite loop. 

E. An exception is thrown at runtime. 

F. The program produces the correct result, with better performance than the original. 

Answer:

Explanation: Changing the code is not useful. In the original code (return f2.compute() + 

f1.join; ) f1 and f2 are run in parallel. The result is joined. 

With the changed code (return f1.join() + f2.compute();) f1 is first executed and finished, 

then is f2 executed. 

Note 1: The join method allows one thread to wait for the completion of another. 

If t is a Thread object whose thread is currently executing, 

t.join(); 

causes the current thread to pause execution until t's thread terminates. 

Note 2: New in the Java SE 7 release, the fork/join framework is an implementation of the 

ExecutorService interface that helps you take advantage of multiple processors. It is 

designed for work that can be broken into smaller pieces recursively. The goal is to use all 

the available processing power to enhance the performance of your application. 

As with any ExecutorService, the fork/join framework distributes tasks to worker threads in 

a thread pool. The fork/join framework is distinct because it uses a work-stealing algorithm. 

Worker threads that run out of things to do can steal tasks from other threads that are still busy. 

Reference: The Java Tutorials, Joins, Fork/Join 


Q44. Given a language code of fr and a country code of FR, while file name represents a resource bundle file name that is not the default? 

A. MessageBundle_fr_FR.properties 

B. MessageBundle_fr_FR.Profile 

C. MessageBundle_fr_FR.Xml 

D. MessageBundle_fr_FR.Java 

E. MessageBundle_fr_FR.locale 

Answer:

Explanation: A properties file is a simple text file. You can create and maintain a properties file with just about any text editor. You should always create a default properties file. The name of this file begins with the base name of your ResourceBundle and ends with the .properties suffix. To support an additional Locale, your localizers will create a new properties file that contains the translated values. No changes to your source code are required, because your program references the keys, not the values. 

For example, to add support for the German language, your localizers would translate the values in LabelsBundle.properties and place them in a file named LabelsBundle_de.properties. Notice that the name of this file, like that of the default file, begins with the base name LabelsBundle and ends with the .properties suffix. 

Reference: The Java Tutorials, Backing a ResourceBundle with Properties Files 


Q45. Given the code fragment: 

/* method declaration */ { 

try { 

String className = "java.lang.String"; 

String fieldname = "somefield"; 

Class c = Class.forName(className); 

Field f = c.getField(fieldname); 

} catch(Exception e) { 

e.printStackTrace(); 

throw e; 

Which two method declarations are valid options to replace /* method declaration */? 

A. public void getMetadata () 

B. public void getMetadat () 

C. public void getMetadata () throws Exception 

D. public void getMetadata () throws NoSuchFieldException 

E. public void getMetadata () throws classNotFoundException 

F. public void getMetadata () throws ClassNotFoundException, NoSuchFieldException. 

Answer: C,F 

Explanation: We must specify that the getMetaData method can throw both ClassNotFoundException (line Class c = Class.forName(className);) and a NoSuchFieldException (line Field f = c.getField(fieldname);). We can do this by either declare that all exception can be thrown or that these two specific exceptions can be thrown 

Note: Valid Java programming language code must honor the Catch or Specify Requirement. This means that code that might throw certain exceptions must be enclosed by either of the following: 

* A try statement that catches the exception. The try must provide a handler for the exception. 

* A method that specifies that it can throw the exception. The method must provide a throws clause that lists the exception. 

Code that fails to honor the Catch or Specify Requirement will not compile. 

Reference: The Java Tutorials, The Catch or Specify Requirement 


Q46. Which three objects must a vendor provide implementations in its JDBC driver? 

A. Time 

B. Date 

C. Statement 

D. RuleSet 

E. Connection 

F. SQLException 

G. DriverManager 

Answer: E,F,G 

Explanation: E: When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application. 

F: An SQLException is an exception that provides information on a database access error or other errors. 

G: DriverManager is the basic service for managing a set of JDBC drivers. 

Reference: The Java Tutorials, Class DriverManager 


Q47. 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? 

A. Compilation fails 

B. 6 

C. 4 

D. 1 

E. 3 

Answer:

Explanation: The program will compile and run. 

Referring to the exhibit there will be six nodes that matches glob:*java. 


Q48. Given: 

public class SampleClass { 

public static void main(String[] args) { 

SampleClass sc = new SampleClass(); 

sc.processCD(); 

private void processCD() { 

try (CDStream cd = new CDStream()) { 

cd.open(); 

cd.read(); 

cd.write("lullaby"); 

cd.close(); 

} catch (Exception e) { 

System.out.println("Exception thrown"); 

class CDStream { 

String cdContents = null; 

public void open() { 

cdContents = "CD Contents"; 

System.out.println("Opened CD stream"); 

public String read() throws Exception { 

throw new Exception("read error"); 

public void write(String str) { 

System.out.println("CD str is: " + str); 

public void close() { 

cdContents = null; 

What is the result? 

A. Compilation CD stream 

B. Opened CD thrown 

C. Exception thrown 

D. Opened CD stream CD str is: lullaby 

Answer:

Explanation: In this example the compilation of line " try (CDStream cd = new CDStream()) {" will fail, as try-with-resources not applicable to variable type CDStream. 

Note: The try-with-resources statement is a try statement that declares one or more resources. A resource is an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource. 

Reference: The Java Tutorials,The try-with-resources Statement 


Q49. Which three must be used when using the Java.util.concurrent package to execute a task that returns a result without blocking? 

A. ExecutorService 

B. Runnable 

C. Future 

D. Callable 

E. Thread 

F. Executor 

Answer: A,D,F 

Explanation: The java.util.concurrent package defines three executor interfaces: 

* (F) Executor, a simple interface that supports launching new tasks. 

* (A) ExecutorService, a subinterface of Executor, which adds features that help manage the lifecycle, both of the individual tasks and of the executor itself. 

* ScheduledExecutorService, a subinterface of ExecutorService, supports future and/or periodic execution of tasks. 

Typically, variables that refer to executor objects are declared as one of these three interface types, not with an executor class type. 

D: The ExecutorService interface supplements execute with a similar, but more versatile submit method. Like execute, submit accepts Runnable objects, but also accepts Callable objects, which allow the task to return a value. 

Reference: The Java Tutorials, Executor Interfaces 


Q50. Given this code fragment: 

try { 

String query = "SELECT * FROM Item"; 

Statement stmt = conn.createStatement(); 

ResultSet rs = stmt.executeQuery(query); 

ResultSetMetaData rsmd = rs.getMetaData(); 

int rowCount = rsmd.getRowCount(); 

System.out.println ("Processing: " + rowCount + " rows."); 

while (rs.next()) { 

// Process each row 

} catch (SQLException se) { 

System.out.println("Error"); 

Assume that the SQL query returns records. What is the result? 

A. Compilation fails. 

B. The program prints Error 

C. An exception is thrown at runtime 

D. The statement at line 16 execute 

Answer:

Explanation: There is no GetRowCount method in java.sql.ResultSetMetaData. 

The following line will not compile: 

int rowCount = rsmd.getRowCount(); 

Reference: java.sql.ResultSetMetaData