Examcollection provides every one of the Oracle certification exam questions and answers that are written on the high specifications of technical accuracy. Examcollection.com is the only site in which offers preparation components for every one of the certification exams. Our certified professionals have got rich knowledge in compiling along with revising the Oracle Oracle 1Z0-805 exam questions. The particular corresponding answers are precise, accurate and throughout details. These are not only very easily understandable but furthermore technical and professional.

2017 Feb 1Z0-805 test question

Q51. You are using a database from XY/Data. What is a prerequisite for connecting to the database using a JDBC 4.0 driver from XY/Data? 

A. Use the JDBC DriverManager.loadDriver method. 

B. Put the XY/data driver into the classpath of your application. 

C. Create an instance of the XY/Data driver class using the new keyword. 

D. Create an Implementation of DriverManager that extends the XY/Data driver 

Answer:

Explanation: First, you need to establish a connection with the data source you want to use. A data source can be a DBMS, a legacy file system, or some other source of data with a corresponding JDBC driver. Typically, a JDBC application connects to a target data source using one of two classes: 

* DriverManager: This fully implemented class connects an application to a data source, which is specified by a database URL. When this class first attempts to establish a connection, it automatically loads any JDBC 4.0 drivers found within the class path (B). Note that your application must manually load any JDBC drivers prior to version 4.0. 

* DataSource: This interface is preferred over DriverManager because it allows details about the underlying data source to be transparent to your application. A DataSource object's properties are set so that it represents a particular data source. 

Note: The JDBC Architecture mainly consists of two layers: First is JDBC API, which provides the application-to-JDBC Manager connection. Second is JDBC Driver API, which supports the JDBC Manager-to-Driver Connection. This has to provide by the vendor of database, you must have notice that one external jar file has to be there in class path for forth type of driver (B). The JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases. The JDBC driver manager ensures that the correct driver is used to access each data source. The driver manager is capable of supporting multiple concurrent drivers connected to multiple heterogeneous databases. 

Reference: The Java Tutorials, Establishing a Connection 


Q52. Given this code fragment: 

ResultSet rs = null; 

try (Connection conn = DriverManager. getConnection (url) ) { 

Statement stmt = conn.createStatement(); 

rs stmt.executeQuery(query); 

//-.. other methods } 

} catch (SQLException se) { 

System.out.println ("Error"); 

Which object is valid after the try block runs? 

A. The Connection object only 

B. The Statement object only 

C. The Result set object only 

D. The Statement and Result Set object only 

E. The connection, statement, and ResultSet objects 

F. Neither the Connection, Statement, nor ResultSet objects 

Answer:

Explanation: Generally, JavaScript has just 2 levels of scope: global and function. But, try/catch is an exception (no punn intended). When an exception is thrown and the exception object gets a variable assigned to it, that object variable is only available within the "catch" section and is destroyed as soon as the catch completes. 


Q53. Given the code fragment: 

try { 

String query = "SELECT * FROM Employee WHERE ID=110"; 

Statement stmt = conn.createStatement(); 

ResultSet rs = stmt.executeQuery(query); // Line 13 

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

} catch (Exception se) { 

System.out.println("Error"); 

Assume that the SQL query matches one record. What is the result of compiling and executing this code? 

A. The code prints error. 

B. The code prints the employee ID. 

C. Compilation fails due to an error at line 13. 

D. Compilation fails due to an error at line 14. 

Answer:

Explanation: Assuming that the connection conn has been set up fine, the code will compile and run fine. 

Note #1: The GetInt method retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language. 

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

A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set. 

A default ResultSet object is not updatable and has a cursor that moves forward only. Thus, you can iterate through it only once and only from the first row to the last row. It is possible to produce ResultSet objects that are scrollable and/or updatable. 

Reference: The Java Tutorials, Interface ResultSet 


Q54. Which two statements are true about RowSet subinterfaces? 

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

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

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

D. 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. 


Q55. Given the code fragment: 

private static void copyContents (File source, File target) { 

try {inputStream fis = new FileInputStream(source); 

outputStream fos = new FileOutputStream (target); 

byte [] buf = new byte [8192]; 

int i; 

while ((i = fis.read(buf)) != -1) { 

fos.write (buf, 0, i); 

//insert code fragment here. Line ** 

System.out.println ("Successfully copied"); 

Which code fragments, when inserted independently at line **, enable the code to compile? 

A. } catch (IOException | NoSuchFileException e) { 

System.out.println(e); 

B. } catch (IOException | IndexOutOfBoundException e) { 

System.out.println(e); 

C. } catch (Exception | IOException | FileNotFoundException e ) { 

System.out.println(e); 

D. } catch (NoSuchFileException e ) { 

System.out.println(e); } 

E. } catch (InvalidPathException | IOException e) { 

System.out.println(e); 

Answer: B,D,E 

Explanation: B: Two mutually exclusive exceptions. Will work fine. 

D: A single exception. Will work fine. 

E: Two mutually exclusive exceptions. Will work fine. 

Note: In Java SE 7 and later, a single catch block can handle more than one type of exception. This feature can reduce code duplication and lessen the temptation to catch an overly broad exception. In the catch clause, specify the types of exceptions that block can handle, and separate each exception type with a vertical bar (|). 

Note 2: NoSuchFileException: Checked exception thrown when an attempt is made to access a file that does not exist. InvalidPathException: Unchecked exception thrown when path string cannot be converted into a Path because the path string contains invalid characters, or the path string is invalid for other file system specific reasons. FileNotFoundException: Signals that an attempt to open the file denoted by a specified pathname has failed. This exception will be thrown by the FileInputStream, FileOutputStream, and RandomAccessFile constructors when a file with the specified pathname does not exist. It will also be thrown by these constructors if the file does exist but for some reason is inaccessible, for example when an attempt is made to open a read-only file for writing. 


Renovate 1Z0-805 free practice exam:

Q56. 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 


Q57. Given the code fragment: 

public class Test { 

public static void main (String [] args) { 

Path path1 = Paths.get("D:\\sys\\asm\\.\\data\\..\\..\\mfg\\production.log"); 

System.out.println(path1.normalize()); 

System.out.println(path1.getNameCount()); 

What is the result? 

A. D:\sys\mfg\production.log 8 

B. D:\\sys\\asm\\.\\data\\. . \\mfg\\production.log 6 

C. D: \\sys\\asm\\.\\data\\. . \\mfg\\production.log 8 

D. D: \sys\mfg\production.log 4 

E. D: \\ sys\\asm\\data\\mfg\\production.log 6 

Answer:

Explanation: The normalize method removes any redundant elements, which includes any 

"." or "directory/.." occurrences. 

The getNameCount method returns the number of elements in the path. Here there are 8 

elements (in the redundant path). 

Reference: The Java Tutorials,Path Operations 


Q58. Which statement creates a low-overhead, low contention random number generator that is isolated to a thread to generate a random number between 1 and 100? 

A. int i = ThreadLocalRandom.current().nextInt (1, 101); 

B. int i = ThreadSaferandom.current().nextInt(1, 101); 

C. int i = (int) Math.random()*.nextInt(1, 101); 

D. int i = (int) Match.random (1, 101); 

E. int i = new Random (). nextInt (100)+1; 

Answer:

Explanation: public class ThreadLocalRandom extends Random A random number generator isolated to the current thread. Like the global Random generator used by the Math class, a ThreadLocalRandom is initialized with an internally generated seed that may not otherwise be modified. When applicable, use ofThreadLocalRandom rather than shared Random objects in concurrent programs will typically encounter much less overhead and contention. Use of ThreadLocalRandom is particularly appropriate when multiple tasks (for example, each a ForkJoinTask) use 

random numbers in parallel in thread pools. 

Usages of this class should typically be of the form: 

ThreadLocalRandom.current().nextX(...) (where X is Int, Long, etc). When all usages are of 

this form, it is never possible to accidently share a ThreadLocalRandom across multiple 

threads. 

This class also provides additional commonly used bounded random generation methods. 


Q59. Given the incomplete pseudo-code for a fork/join framework applications: 

submit (Data) { if (Data.size < SMALL_ENOUGH) { _________(Data); // line X } else { List<Data> x = _________________(Data); // line Y for(Data d: x ______________(d); // line Z } 

And give the missing methods: 

Process, submit, and splitInHalf 

Which three insertions properly complete the pseudo-code? 

A. Insert submit at line X 

B. Insert splitHalf at line X 

C. Insert process at line X 

D. Insert process at line Y 

E. Insert splitHalf at line Y 

F. Insert process at line Z 

G. Insert submit at line Z 

Answer: C,E,G 

Explanation: C: If Data.Size is "small enough" then process it directly. 

E: Else we split it in half. 

G: We use a recursive submit (of the splitted Data). 


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

A. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName ("UTF - 8"), new 

openOption [] 

{StandardOpenOption.CREATE, StandardOpenOption.Append, 

StandardOpenOption.DSYNC}};} 

B. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName ("UTF - 8"), new 

openOption [] {StandardOpenOption.APPEND, StandardOpenOption.SYNC));){ 

C. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName ("UTF - 8"), new 

openOption [] {StandardOpenOption.APPEND, StandardOpenOption.DSYNC} 

D. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName ("UTF – 8"), new 

openOption [] 

{StandardOpenOption.CREATENEW, StandardOpenOption.APPEND, 

StandardOpenOption.SYNC}} } 

E. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName (“UTF - 8”), new openOption [] {StandardOpenOption.APPEND, StandardOpenOption.ASYNC});) { 

Answer:

Explanation: StandardOpenOption should be both APPEND (if the file is opened for WRITE access then bytes will be written to the end of the file rather than the beginning)and DSYNC (Requires that every update to the file's content be written synchronously to the underlying storage device.). 

Note 1: The newBufferedWriter method Opens or creates a file for writing, returning a BufferedWriter that may be used to write text to the file in an efficient manner. The options parameter specifies how the the file is created or opened. If no options are present then this method works as if the CREATE, TRUNCATE_EXISTING, and WRITE options are present. In other words, it opens the file for writing, creating the file if it doesn't exist, or initially truncating an existing regular-file to a size of 0 if it exists. 

Note 2: public static final StandardOpenOption APPEND If the file is opened for WRITE access then bytes will be written to the end of the file rather than the beginning. If the file is opened for write access by other programs, then it is file system specific if writing to the end of the file is atomic. 

Reference: java.nio.file.Files 

java.nio.file Enum StandardOpenOption