[Free] 2017(Aug) CollectDumps Testking Oracle 1Z0-805 Dumps with VCE and PDF 51-60

CollectDumps 2017 Aug Oracle Official New Released 1Z0-805
100% Free Download! 100% Pass Guaranteed!

Upgrade to Java SE 7 Programmer

Question No: 51


class Fibonacci extends RecursiveTasklt;Integergt; { final int n;

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

if (n lt;= 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?

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

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

  3. The program produces an incorrect result.

  4. The program goes into an infinite loop.

  5. An exception is thrown at runtime.

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

Answer: B

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,


causes the current thread to pause execution until t#39;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

Question No: 52


public static void main(String[] args) throws Exception { try {


} catch(Exception e) {

Throwable [] t = e.getSuppressed();



public static void processFile() throws IOException { try (FileReader fr = new FileReaderquot;logfilesrc.txtquot;); FileWriter fw = new FileWriter(quot;logfiledest.txtquot;)) {{

java.util.zip.ZipFile zf = new java.util.zip.ZipFile(quot;alllogs.zipquot;); System.out.println(quot;Created files for logsquot;);



The getSuppressed method returns an array of .

  1. All exceptions that were thrown in the processFile method but were suppressed.

  2. Exceptions suppressed because that are not declared in the throws clause.

  3. Only runtime exceptions that were thrown in the processFile method but were suppressed.

  4. Only runtime exceptions that were thrown in the processFile method but were not declared in throws clause.

Answer: A

Explanation: The GetSuppressed() method returns an array containing all of the exceptions that were suppressed, typically by the try-with-resources statement, in order to

deliver this exception.

If an exception is thrown from the try block and one or more exceptions are thrown from the try-with-resources statement, then those exceptions thrown from the try-with-resources statement are suppressed.

Reference: The Java Tutorials, Suppressed Exceptions

Question No: 53

Given the code fragment:

  1. public static getFileSize () throws IOException {

  2. path file = paths.get (quot;ex.txtquot;);

  3. //insert code here

  4. System.out.println (quot;size: quot; attr.size());

15. }

public static getFileSize () throws IOException { Path file = Paths.get (quot;ex.txtquot;);

//insert code here Line ** System.out.println (quot;size: quot; attr.size());


Which two fragments, when inserted independently at line **, enable printing of the file size?

  1. BasicFileAttributes attr = Files.readAttributes (file, BasicFileAttributes.class);

  2. PosixFileAttributes attr = Files.readAttributes (file, posixFileAttributes.class);

  3. DosFileAttributes attr = Files.readAttributes (file, dosAttributes.class);

  4. FileStore attr = Files.getFileStore (file);

  5. AclFileAttributeview attr = Files.getFileAttributeView(File, AclFileAttributeview.class);

Answer: A,B

Explanation: A: The BasicFileAttributes has a size method. B: The PosixFileAttributes has a size method.

Question No: 54

Which two statements are true about RowSet subinterfaces?

  1. A jdbcRowSet object provides a JavaBean view of a result set.

  2. A cachedRowSet provides a connected view of the database.

  3. A FilteredRowSet object filter can be modified at any time.

  4. A webRowSet returns JSON-formatted data.

Answer: A,C

Explanation: A: JdbcRowSet Mmakes results available as a JavaBean component C: FilteredRowSet implements lightweight querying, usingjavax.sql.rowset.Predicate

The predicate set on a FilteredRowSet object applies a criterion on all rows in a RowSet object to manage a subset of rows in aRowSet object. This criterion governs the subset of rows that are visible and also defines which rows can be modified, deleted or inserted.

Therefore, the predicate set on a FilteredRowSet object must be considered as bi- directional and the set criterion as the gating mechanism for all views and updates to the FilteredRowSet object. Any attempt to update the FilteredRowSet that violates the criterion will result in a SQLException object being thrown.

The FilteredRowSet range criterion can be modified by applying a new Predicate object to the FilteredRowSet instance at any time. This is possible if no additional references to the FilteredRowSet object are detected. A new filter has has an immediate effect on criterion enforcement within the FilteredRowSet object, and all subsequent views and updates will be subject to similar enforcement.

Note: The RowSet interface, a subinterface of ResultSet , was introduced with JDBC 2. Because a RowSet is a ResultSet , you can use any of the ResultSet processing methods previously discussed. But RowSet s tend to be more self-contained; you typically do not need to specify a driver, and performing queries is done in a new way. You call setCommand() to specify the query and execute() to perform the query (this takes the place of creating a Statement and calling its executeQuery() method).

Incorrect answer:

B: CachedRowSet caches results in memory; disconnected Rowset.

D: WebRowSet converts between XML data and RowSet. The data is not JSON formatted.

Note: JSON or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages.

Question No: 55

Consider the following five methods:

Collectdumps 2017 PDF and VCE

Which method should you use to connect to a java Db database with JDBC 4.0, but not with previous versions of JDBC?

  1. getConnectionA

  2. getConnectionB

  3. getConnectionC

  4. getConnectionD

  5. getConnectionE

Answer: D

Explanation: Note on D not E: Prior to JDBC 4.0, we relied on the JDBC URL to define a data source connection. Now with JDBC 4.0, we can get a connection to any data source by simply supplying a set of parameters (such as host name and port number) to a

standard connection factory mechanism. New methods were added to Connection and Statement interfaces to permit improved connection state tracking and greater flexibility when managing Statement objects in pool environments.

Note on that an embedded driver is no longer needed (not A, B, C):

Thanks to the Java SE Service Provider mechanism included in Mustang, Java developers no longer need to explicitly load JDBC drivers using code like Class.forName() to register a JDBC driver. The DriverManager class takes care of this by automatically locating a suitable driver when the DriverManager.getConnection() method is called. This feature is backward-compatible, so no changes are needed to the existing JDBC code.

In JDBC 4.0, we no longer need to explicitly load JDBC drivers using Class.forName(). When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from among the JDBC drivers that were loaded at initialization and those loaded explicitly using the same class loader as the current application.

Assume that we need to connect to an Apache Derby database, since we will be using this in the sample application explained later in the article: Class.forName(quot;org.apache.derby.jdbc.EmbeddedDriverquot;);

Connection conn =

DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);

But in JDBC 4.0, we don#39;t need the Class.forName() line. We can simply call getConnection() to get the database connection.

Question No: 56

Given the code fragment:

public static void main(String[] args) { Path dir = Paths.get(quot;d:\\companyquot;);

// insert code here. Line **

for (Path entry: stream) { System.out.println(entry.getFileName());


} catch (IOException e) {

System.err.println(quot;Caught IOException: quot; e.getMessage());



Which two try statements, when inserted at line 11, enable you to print files with the extensions.java, .htm, end and .jar.

  1. try (DirectoryStreamlt;pathgt; stream = Files.newDirectoryStream(dir, quot;*.{java, htm, jar}quot;)) {

  2. try (DirectoryStreamlt;pathgt; stream = Files.newDirectoryStream(dir, quot;*.[java, htm, jarquot;] }}


  3. try (DirectoryStreamlt;pathgt; stream = Files.newDirectoryStream(dir, quot;*.{java*, htm*, jar*}quot;}} {

  4. try (DirectoryStreamlt;pathgt; stream = Files.newDirectoryStream(dir, quot;**.{java, htm, jar}quot;))


Answer: A,D

Reference: The Java Tutorials Finding Files

What Is a Glob?

Question No: 57

Given the code fragment:

Locale loc1 = Locale.getDefault ();

ResourceBundle messages = ResourceBundle.getBundle(quot;MessageBundlequot;, loc1);

Which two statements are a valid way to re-assign a resource bundle to a different Locale?

  1. loc1 = ResourceBundle.getBundle (quot;MessageBundlequot;, Locale.CHINA);

  2. loc1 = ResourceBundle.getBundle (quot;MessageBundlequot;, new Locale (quot;esquot;, quot;ESquot;));

  3. messages = ResourceBundle.getBundle (quot;messageBundlequot;, new Locale (quot;esquot;, quot;ESquot;));

  4. messages = ResourceBundle.getBundle (quot;MessageBundlequot;, Locale.CHINA);

Answer: C,D

Question No: 58


public class TemperatureSensor { public TemperatureSensor () {


public double getCurrTemp () {

// . . . method to retrieve temperature from a sensor Return temp;



Which three changes should you make to apply the singleton design pattern to this class?

  1. Make the class abstract.

  2. Add a method to return a singleton class type.

  3. Change the access of the constructor to private.

  4. Add a public constructor that takes a single argument.

  5. Change the class to implement the singleton interface.

  6. Add a private static final variable that is initialized to new TemperatureSensor{};

  7. Add a public static method that returns the class variable of type

Answer: C,F,G

Explanation: C: We provide a default Private constructor

F, G: We write a public static getter or access method (G) to get the instance of the Singleton Object at runtime. First time the object is created inside this method as it is null. Subsequent calls to this method returns the same object created as the object is globally declared (private) (F) and the hence the same referenced object is returned.

Note: Java has several design patterns Singleton Pattern being the most commonly used. Java Singleton pattern belongs to the family of design patterns, that govern the instantiation process. This design pattern proposes that at any time there can only be one instance of a singleton (object) created by the JVM.

The class’s default constructor is made private (C), which prevents the direct instantiation of the object by others (Other Classes). A static modifier is applied to the instance method that returns the object as it then makes this method a class level method that can be accessed without creating an object.

Question No: 59

Given the error message when running you application:

Exception in thread “main” java.util.MissingResourceException: can’t find bundle for base name messageBundle, Locale

And given that the Message Bundle.properties file has been created, exists on your disk, and is properly formatted.

What is the cause of the error message?

  1. The file is not in the environment PATH.

  2. The file is not in the CLASSPATH.

  3. The file is not in the JJAVAPATH.

  4. You cannot use a file to store a ResourceBundle.

Answer: B

Question No: 60

Which two statements are true regarding the try with resources statement?

  1. The resources declared in a try with resources statement are not closed automatically if an exception occurs inside the try block.

  2. In a try with resources statement, any catch or finally block is run after the resources have been closed.

  3. The close methods of resources are called in the reverse order of their creation.

  4. All the resources must implement the java.io.closeable interface.

Answer: B,D

Explanation: B: Prior to Java SE 7, you can use a finally block to ensure that a resource is closed regardless of whether the try statement completes normally or abruptly.

A try-with-resources statement can have catch and finally blocks just like an ordinary trystatement. In a try-with-resources statement, any catch or finally block is run after the resources declared have been closed.

D: 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 implementjava.io.Closeable, can be used as a resource.

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

100% Free Download!
Download Free Demo:1Z0-805 Demo PDF
100% Pass Guaranteed!
Download 2017 CollectDumps 1Z0-805 Full Exam PDF and VCE

CollectDumps ExamCollection Testking
Lowest Price Guarantee Yes No No
Up-to-Dated Yes No No
Real Questions Yes No No
Explanation Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

2017 CollectDumps IT Certification PDF and VCE