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

CollectDumps 2017 Aug Oracle Official New Released 1Z0-805
100% Free Download! 100% Pass Guaranteed!
http://www.CollectDumps.com/1Z0-805.html

Upgrade to Java SE 7 Programmer

Question No: 41

Which code fragment is required to load a JDBC 3.0 driver?

  1. DriverManager.loadDriver(“org.xyzdata.jdbc.network driver”);

  2. Class.forname (“org.xyzdata.jdbc.NetWorkDriver”);

  3. Connection con = Connection.getDriver (“jdbc:xyzdata: //localhost:3306/EmployeeDB”);

  4. Connection con = Drivermanager.getConnection (“jdbc:xyzdata: //localhost:3306/EmployeeDB”);

Answer: B

Explanation: Note that your application must manually load any JDBC drivers prior to version 4.0.

The simplest way to load a driver class is to call the Class.forName() method.

If the fully-qualified name of a class is available, it is possible to get the corresponding Class using the static method Class.forName().

Question No: 42

What statement is true about thread starvation?

  1. Thread quot;Aquot; is said to be starved when it is frequently unable to gain access to a resource that it shares with another thread.

  2. Thread quot;Aquot; is said to be starved when it is blocked waiting for Thread quot;13,quot; which in turn waiting for Thread quot;A.quot;

  3. Starvation can occur when threads become so busy responding to other threads that they move forward with their other work.

  4. When some of the processors in a multi-processor environment go offline and the live thread(s) blocked waiting for CPU cycles, that blocking is referred to as quot;thread starvation.quot;

Answer: A

Explanation: Starvation describes a situation where a thread is unable to gain regular access to shared resources and is unable to make progress. This happens when shared resources are made unavailable for long periods by quot;greedyquot; threads. For example, suppose an object provides a synchronized method that often takes a long time to return. If one thread invokes this method frequently, other threads that also need frequent synchronized access to the same object will often be blocked.

Reference: The Java Tutorials, Starvation and Livelock

Question No: 43

Given the code fragment:

static void addContent () throws Exception { Path path = Paths.get(quot;D:\\company\\report.txtquot;);

UserPrincipal owner = path.getFileSystem().getUserPrincipalLookupService().lookupPrincipalByName(quot;Bobquot;);

Files.setOwner(path, owner);

// insert code here – Line ** br.write(quot;this is a text message quot;);

}

System.out.println(quot;successquot;);

}

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?

  1. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName (quot;UTF – 8quot;), new openOption []

    {StandardOpenOption.CREATE, StandardOpenOption.Append, StandardOpenOption.DSYNC}};}

    {

  2. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName (quot;UTF – 8quot;), new openOption [] {StandardOpenOption.APPEND, StandardOpenOption.SYNC));){

  3. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName (quot;UTF – 8quot;), new openOption [] {StandardOpenOption.APPEND, StandardOpenOption.DSYNC}

  4. try (BufferWriter br = Files.newBufferedWriter (path, Charset.forName (quot;UTF – 8quot;), new openOption []

    {StandardOpenOption.CREATENEW, StandardOpenOption.APPEND, StandardOpenOption.SYNC}}

    }

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

Answer: C

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

Question No: 44

Which two statements are true?

  1. Implementing a DAO often includes the use of factory.

  2. To be implemented properly, factories rely on the private keyword.

  3. Factories are an example of the OO principle quot;program to an interface.quot;

  4. Using factory prevents your replication from being tightly coupled with a specific Singleton

  5. One step in implementing a factory is to add references from all the classes that the factory will merge.

Answer: A,C

Explanation: A: 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.

C: The essence of the Factory method Pattern is to quot;Define an interface for creating an object, but let the classes which implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.quot;

Note: The factory method pattern is an object-oriented design pattern to implement the concept of factories. Like other creational patterns, it deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The creation of an object often requires complex processes not appropriate to include within a composing object. The object#39;s creation may lead to a significant duplication of code, may require information not accessible to the composing object, may not provide a sufficient level of abstraction, or may otherwise not be part of the composing object#39;s concerns. The factory method design pattern handles these problems by defining a separate method for creating the objects, whichsubclasses can then override to specify the derived type of product that will be created.

Some of the processes required in the creation of an object include determining which object to create, managing the lifetime of the object, and managing specialized build-up and tear-down concerns of the object.

Question No: 45

Which five items are provided by the Java concurrency utilities?

  1. High-performance, flexible thread pools

  2. Dynamic adjustment of thread priorities

  3. Collection classes designed for concurrent access

  4. Atomic variables

  5. synchronized wrappers for collection classes in the java.util package,

  6. Asynchronous execution of tasks

  7. Counting semaphores

  8. Concurrent collection sorting implementations

Answer: A,C,D,E,G

Explanation: The Java 2 platform includes a new package of concurrency utilities. These

are classes that are designed to be used as building blocks in building concurrent classes or applications. Just as the collections framework simplified the organization and manipulation of in-memory data by providing implementations of commonly used data structures, the concurrency utilities simplify the development of concurrent classes by providing implementations of building blocks commonly used in concurrent designs. The concurrency utilities include a high-performance, flexible thread pool; a framework for asynchronous execution of tasks; a host of collection classes optimized for concurrent access; synchronization utilities such as counting semaphores (G); atomic variables; locks; and condition variables.

The concurrency utilities includes:

  • Task scheduling framework. The Executor interface standardizes invocation, scheduling, execution, and control of asynchronous tasks according to a set of execution policies.

    Implementations are provided that enable tasks to be executed within the submitting thread, in a single background thread (as with events in Swing), in a newly created thread, or in a thread pool, and developers can create customized implementations of Executor that support arbitrary execution policies. The built-in implementations offer configurable policies such as queue length limits and saturation policy that can improve the stability of applications by preventing runaway resource use.

  • Fork/join framework. Based on the ForkJoinPool class, this framework is an implementation of Executor. It is designed to efficiently run a large number of tasks using a pool of worker threads (A) . A work-stealing technique is used to keep all the worker threads busy, to take full advantage of multiple processors.

  • (C) Concurrent collections. Several new collections classes were added, including the new Queue, BlockingQueue and BlockingDeque interfaces, and high-performance, concurrent implementations of Map, List, and Queue. See the Collections Framework Guide for more information.

  • (D) Atomic variables. Utility classes are provided that atomically manipulate single variables (primitive types or references), providing high-performance atomic arithmetic and compare-and-set methods. The atomic variable implementations in the java.util.concurrent.atomic package offer higher performance than would be available by using synchronization (on most platforms), making them useful for implementing high- performance concurrent algorithms and conveniently implementing counters and sequence number generators.

  • (E) Synchronizers. General purpose synchronization classes, including semaphores, barriers, latches, phasers, and exchangers, facilitate coordination between threads.

  • Locks. While locking is built into the Java language through the synchronized keyword, there are a number of limitations to built-in monitor locks. The java.util.concurrent.locks package provides a high-performance lock implementation with the same memory

    semantics as synchronization, and it also supports specifying a timeout when attempting to acquire a lock, multiple condition variables per lock, nonnested (quot;hand-over-handquot;) holding of multiple locks, and support for interrupting threads that are waiting to acquire a lock.

  • Nanosecond-granularity timing. The System.nanoTime method enables access to a nanosecond-granularity time source for making relative time measurements and methods that accept timeouts (such as the BlockingQueue.offer, BlockingQueue.poll, Lock.tryLock, Condition.await, and Thread.sleep) can take timeout values in nanoseconds. The actual precision of the System.nanoTime method is platform-dependent.

Reference: Java SE Documentation, Concurrency Utilities

Question No: 46

Given:

import java.io.*;

public class SampleClass {

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

String dirName = args[0]; File dir = new File(dirName);

File.createTempFile(quot;tempquot;, quot;logquot;, dir);

} catch (NullPointerException | IOException e) {

e = new IOException(quot;Error while creating temp filequot;); throw e;

}

}

}

What is the result?

  1. Compilation fails.

  2. An IOException with the default message is thrown at runtime.

  3. An IOException with the message Error while creating temp file is thrown at runtime.

  4. A temporary file is created in the specified directory.

Answer: A

Explanation: The multi-catch parameter e may not be assigned. The compilation will fail at line:

e = new IOException(quot;Error while creating temp filequot;);

Question No: 47

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?

  1. MessageBundle_fr_FR.properties

  2. MessageBundle_fr_FR.Profile

  3. MessageBundle_fr_FR.Xml

  4. MessageBundle_fr_FR.Java

  5. MessageBundle_fr_FR.locale

Answer: A

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

Question No: 48

Given:

Person

public Person(int id) public int getid()

public String getContactDetails()

public void setContactDetails(String contactDetails) public String getName()

public void setName(String name)

public Person getPerson(int id) throws Exception public void createPerson(int id) throws Exception public Person deletePerson(int id) throws Exception public void updatePerson(Person p) throws Exception

Which group of methods is moved to a new class when implementing the DAO pattern?

  1. public int getId ()

    public String getContractDetails ()

    public void setContactDetails (String ContactDetails) public void getName ()

    public Person setName (String name)

  2. public int getId ()

    public String getContractDetails () public void getName ()

    public person getPerson (int id) throws Exception

  3. public void setContactDetails(String contactDetails) public void setName (String name)

  4. public person getPerson(int id) throws Exception public void createPerson (person p) throws exception public void deleteperson(int id) throws Exception public void updatePerson (Person p) throws Exception

Answer: D

Explanation: We move the most abstract highest level methods into a separate class.

Note: Data Access Object

Abstracts and encapsulates all access to a data source

Manages the connection to the data source to obtain and store data

Makes the code independent of the data sources and data vendors (e.g. plain-text, xml, LDAP, MySQL, Oracle, DB2)

Question No: 49

Given the code fragment:

SimpleDateFormat sdf = new SimpleDateFormat(quot;zzzzquot;, Locale.US); System.out.println (quot;Result: quot; sdf.format(today) ) ;

What type of result is printed?

  1. Time zone abbreviation

  2. Full-text time zone name

  3. Era

  4. Julian date

  5. Time of the Epoch (in milliseconds)

Answer: B

Question No: 50

The advantage of a CallableStatement over a PreparedStatement is that it:

  1. Is easier to construct

  2. Supports transactions

  3. Runs on the database

  4. Uses Java instead of native SQL

Answer: C

Explanation: A Statement is an interface that represents a SQL statement. You execute Statement objects, and they generate ResultSet objects, which is a table of data representing a database result set.

There are three different kinds of statements:

  • Statement: Used to implement simple SQL statements with no parameters.

  • PreparedStatement: (Extends Statement.) Used for precompiling SQL statements that might contain input parameters.

  • CallableStatement: (Extends PreparedStatement.) Used to execute stored procedures that may contain both input and output parameters.

A stored procedure is a group of SQL statements that form a logical unit and perform a particular task, and they are used to encapsulate a set of operations or queries to execute on a database server.

Reference: The Java Tutorials: Executing Queries

Using Stored Procedures

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
PDF VCE Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

2017 CollectDumps IT Certification PDF and VCE