[Free] 2018(Jan) EnsurePass Examcollection Oracle 1Z0-805 Dumps with VCE and PDF 11-20

2018 Jan Oracle Official New Released 1Z0-805
100% Free Download! 100% Pass Guaranteed!

Upgrade to Java SE 7 Programmer

Question No: 11

Given the fragment:

public class CustomerApplication { public static void main (String [] args) {

CustomerDAO custDao = new CustomerDAOMemoryImp1 ();

// . . . other methods



Which two valid alternatives to line 3 would decouple this application from a specific implementation of customerDAO?

  1. CustomerDAO custDao = new customerDAO();

  2. CustomerDAO custDao = (CustomerDAO) new object();

  3. CustomerDAO custDao = CustomerDAO.getInstance();

  4. CustomerDAO custDao = (CustomerDAO) new CustomerDAOmemoryImp1();

  5. CustomerDAO custDao = CustomerDAOFactory.getInstance();

Answer: C,E Explanation:

Note: Data Access Layer has proven good in separate business logic layer and persistent layer. The DAO design pattern completely hides the data access implementation from its

clients. The interfaces given to client does not changes when the underlying data source mechanism changes. this is the capability which allows the DAO to adopt different access scheme without affecting to business logic or its clients. generally it acts as a adapter between its components and database. The DAO design pattern consists of some factory classes, DAO interfaces and some DAO classes to implement those interfaces.

Question No: 12

Given a resource bundle MessageBundle, what is the name of the default bundle file?

  1. MessageBundle.profile

  2. MessageBundle.xml

  3. MessageBundle.java

  4. MessageBundle.properties

Answer: D

Explanation: A properties file is a simple text file. 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.

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

Question No: 13

Given the code fragment: public class Test {

public static void main (String [] args) {

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

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



What is the result?

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

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

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

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

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

Answer: A

Explanation: The normalize method removes any redundant elements, which includes any quot;.quot; or quot;directory/..quot; 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

Question No: 14

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?

  1. Use the JDBC DriverManager.loadDriver method.

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

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

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

Answer: B

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#39;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

    Question No: 15

    Given the following code fragment: public class Calc {

    public static void main (String [] args) {

    //* insert code here Line **

    System.out.print(quot;The decimal value isquot; var);



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

    1. int var = 0b_1001;

    2. long var = 0b100_01L;

    3. float var = 0b10_01;

    4. float var = 0b10_01F;

    5. double var = 0b10_01;

    6. double var = 0b10_01D;

    Answer: B,C,E Explanation: B: output 17 C: output 9.0

    E: output 9.0

    Not A: A _ character cannot begin a number.

    Not D: A float cannot be defined as a binary number (with literal B) Not F: A float cannot be defined as a decimal number (with literal D)

    Note 1:

    In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example. to separate groups of digits in numeric literals, which can improve the readability of your code.

    For instance, if your code contains numbers with many digits, you can use an underscore character to separate digits in groups of three, similar to how you would use a punctuation mark like a comma, or a space, as a separator.

    You can place underscores only between digits; you cannot place underscores in the following places:

    • At the beginning or end of a number (not A)

    • Adjacent to a decimal point in a floating point literal

    • Prior to an F or L suffix

    • In positions where a string of digits is expected

      Note 2: An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1.

      Values of the integral types byte, short, int, and long can be created from int literals. Values of type long that exceed the range of int can be created from long literals. Integer literals can be expressed by these number systems:

      Decimal: Base 10, whose digits consists of the numbers 0 through 9; this is the number system you use every day

      Hexadecimal: Base 16, whose digits consist of the numbers 0 through 9 and the letters A through F

      Binary: Base 2, whose digits consists of the numbers 0 and 1 (you can create binary literals in Java SE 7 and later)

      Reference: The Java Tutorials, Primitive Data Types: Using Underscore Characters in Numeric Literals Integer Literals

      Question No: 16

      Given the code fragment:

      String query = quot;SELECT ID FROM Employeequot;; \\ Line 1 try (Statement stmt = conn.CreateStatement()) { \\ Line 2 ResultSet rs = stmt.executeQuery(query); \\ Line 3

      stmt.executeQuery (quot;SELECT ID FROM Customerquot;); \\ Line 4 while (rs.next()) {

      \\process the results

      System.out.println (quot;Employee ID: quot; rs.getInt(quot;IDquot;) );


      } catch (Exception e) { system.out.println (quot;Errorquot;);


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

      1. The program prints employees IDs.

      2. The program prints customer IDs.

      3. The program prints Error.

      4. Compilation fails on line 13.

      Answer: A

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


      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

      Question No: 17


      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(quot;lullabyquot;);


      } catch (Exception e) { System.out.println(quot;Exception thrownquot;);



      class CDStream {

      String cdContents = null; public void open() { cdContents = quot;CD Contentsquot;;

      System.out.println(quot;Opened CD streamquot;);


      public String read() throws Exception { throw new Exception(quot;read errorquot;);


      public void write(String str) { System.out.println(quot;CD str is: quot; str);


      public void close() { cdContents = null;


      What is the result?

      1. Compilation CD stream

      2. Opened CD thrown

      3. Exception thrown

      4. Opened CD stream CD str is: lullaby

      Answer: A

      Explanation: In this example the compilation of line quot; try (CDStream cd = new CDStream()) {quot; 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

      Question No: 18

      Two companies with similar robots have merged. You are asked to construct a new program that allows the features of the robots to be mixed and matched using composition. Given the code fragments:

      public class CrusherRobot { public void walk () {}

      public void positionArm (int x, int y, int z) {} public void raiseHammer() {}

      public void dropHammer() {}


      public class GripperRobot { public void walk() {}

      public void moveArm (int x, int y, int z) {} public void openGripper () {}

      public void closeGripper() {}


      When applying composition to these two classes, what functionality should you extract into a new class?

      1. A new BasicRobot class that provides walking.

      2. A new BasicRobot class that combines gripping and hammering.

      3. A new BasicRobotFactory class to construct instances of GripperRobot.

      4. A new BasicRobotFactory class to construct instances of CrusherRobot.

      Answer: B

      Question No: 19

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

      1. ExecutorService

      2. Runnable

      3. Future

      4. Callable

      5. Thread

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

    Question No: 20

    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?

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

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

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

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

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

    Answer: A

    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.

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

    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

    2018 EnsurePass IT Certification PDF and VCE

    Leave a Comment


    Your email address will not be published. Required fields are marked *