[Free] 2018(Jan) EnsurePass Examcollection Oracle 1z0-804 Dumps with VCE and PDF 81-90

Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-804
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-804.html

Java SE 7 Programmer II

Question No: 81

Given:

Ensurepass 2018 PDF and VCE

Which two are true?

  1. Thread is printed

  2. Runnable is printed

  3. No output is produced

  4. No new threads of execution are started within the main method

  5. One new thread of execution is started within the main method

  6. Two new threads of exclusion are started within the main method

Answer: C,D

Question No: 82

Which class(es) safely protects the doIt () method from concurrent thread access?

Ensurepass 2018 PDF and VCE

  1. Option A

  2. Option B

  3. Option C

  4. Option D

Answer: A,D Explanation:

only A und D possible

It should be pointed out that: public void blah() { synchronized (this) {

// do stuff

}}

is semantically equivalent to: public synchronized void blah() {

// do stuff

}

Incorrect answer:

B: A constructor cannot be synchronized. () Object cannot be resolved to a type C: in static context (static void main !) no reference to this possible

Question No: 83

Given:

Ensurepass 2018 PDF and VCE

From what threading problem does the program suffer?

  1. deadlock

  2. livelock

  3. starvation

  4. race condition

Answer: B Explanation:

A thread often acts in response to the action of another thread. If the other thread#39;s action

is also a response tothe action of another thread, then livelock may result. As with deadlock, livelocked threads are unable to makefurther progress.

However, the threads are not blocked – they are simply too busy responding to each other to resume work.

This is comparable to two people attempting to pass each other in a corridor: Alphonse moves to his left to let

Gaston pass, while Gaston moves to his right to let Alphonse pass. Seeing that they are still blocking eachother, Alphone moves to his right, while Gaston moves to his left.

They#39;restill blocking each other, so.

Question No: 84

Given the interface:

Public interface Idgenerator { int getNextId();

}

Which class implements IdGenerator in a thread-safe manner, so that no threads can get a duplicate id valuecurrent access?

  1. Public class generator Implements IdGenerator { Private AtomicInteger id = new AtomicInteger (0); return id.incrementAndget();

    }}

  2. Public class Generator Implements idGenerator { private int id = 0;

    return id;

    }}

  3. Public class Generator Implements IdGenerator { private volatile int Id = 0;

    return Id;

    }

  4. Public class Generator Implements IdGenerator { private int id = 0;

    public int getNextId() {

    synchronized (new Generator()) { return id;

    }}}

  5. Public class Generator Implements IdGenerator { private int id = 0;

public int getnextId() { synchronized (id) { return id;

}}}

Answer: D Explanation:

Code that is safe to call by multiple threads simultaneously is called thread safe. If a piece of code is threadsafe, then it contains no race conditions. Race condition only occur when multiple threads update sharedresources. Therefore it is important to know what resources Java threads share when executing.

In Java you can mark a method or a block of code as synchronized. Synchronized blocks can be used to avoidrace conditions.

A, B, C : false: wrong Implementation ( missing int getNextId(); ) E: false: synchronized (mutex Object! not Simple Data Type)

Question No: 85

Given the code fragment:

Ensurepass 2018 PDF and VCE

What is the result?

  1. Null B D

  2. Null B null D

  3. B D

  4. D

  5. An exception is thrown at runtime

Answer: C

Question No: 86

Given:

ConcurrentMap lt;String, Stringgt; PartList = new ConcurrentMaplt;gt;();

Which fragment puts a key/value pair in partList without the responsibility of overwriting an

existing key?

  1. partList.out(key,quot;Blue Shirtquot;);

  2. partList.putIfAbsent(key,quot;Blue Shirtquot;);

  3. partList.putIfNotLocked (key,quot;Blue Shirtquot;);

  4. partList.putAtomic(key,quot;Blue Shirtquot;)

  5. if (!partList.containsKey(key)) partList.put (key,quot;Blue Shirtquot;);

Answer: B Explanation:

putIfAbsent(K key, V value)

If the specified key is not already associated with a value, associate it with the given value. 40

Reference:java.util.concurrent,Interface ConcurrentMaplt;K,Vgt;

Question No: 87

Give:

Ensurepass 2018 PDF and VCE

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

  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: D Explanation:

join() does not proceed until the task#39;s result has been computed. Here we start to wait beforedoing the computing. The code will not finish.

Question No: 88

Given:

import java.util.concurrent.atomic.AtomicInteger; public class AtomicCounter {

private AtomicInteger c = new AtomicInteger(0); public void increment() {

// insert code here

}

}

Which line of code, inserted inside the increment () method, will increment the value of c?

  1. c.addAndGet();

  2. c ;

  3. c = c 1;

  4. c.getAndIncrement ();

Answer: D

Explanation: getAndIncrement public final int getAndIncrement()

Atomically increment by one the current value. Reference:java.util.concurrent.atomic

Question No: 89

Given the following incorrect program:

Ensurepass 2018 PDF and VCE

Which two changes make the program work correctly?

  1. Results must be retrieved from the newly created MyTask instances and combined.

  2. The threshold value must be increased so that the overhead of task creation does not dominate the cost ofcomputation.

  3. The midpoint computation must be altered so that it splits the workload in an optimal manner.

  4. The compute () method must be changed to return an Integer result.

  5. The compute () method must be enhanced to (fork) newly created tasks.

  6. The myTask class must be modified to extend RecursiveAction instead of RecursiveTask

Answer: A,D

Explanation:

Note 1: A RecursiveTask is a recursive result-bearing ForkJoinTask.

Note 2: The invokeAll(ForkJoinTasklt;?gt;… tasks) forks the given tasks, returning when isDone holds for eachtask or an (unchecked) exception is encountered, in which case the exception is rethrown.

Note 3: Using the fork/join framework is simple. The first step is to write some code that performs a segmentof the work. Your code should look similar to this:

if (my portion of the work is small enough) do the work directly

else

split my work into two pieces

invoke the two pieces and wait for the results

Wrap this code as a ForkJoinTask subclass, typically as one of its more specialized types RecursiveTask

(which can return a result) or RecursiveAction.

Question No: 90

How many Threads are created when passing task to an Executor instance?

  1. A new Thread is used for each task.

  2. A number of Threads equal to the number of CPUs Is used to execute tasks.

  3. A single Thread Is used to execute all tasks.

  4. A developer-defined number of Threads is used to execute tasks.

  5. A number of Threads determined by system load is used to execute tasks.

  6. The method used to obtain the Executor determines how many Threads are used to execute tasks.

Answer: F Explanation:

The Executor interface provides a single method, execute, designed to be a drop-in replacementfor a common thread-creation idiom. If r is a Runnable object, and e is an Executor object you can replace(new Thread(r)).start();

with e.execute(r);

However, the definition of execute is less specific. The low-level idiom creates a new

thread and launches it

immediately. Depending on the Executor implementation, execute may do the same thing, but is more likely to

use an existing worker thread to run r, or to place r in a queue to wait for a worker thread to become available.

Reference: The Java Tutorial,The Executor Interface

100% Ensurepass Free Download!
Download Free Demo:1z0-804 Demo PDF
100% Ensurepass Free Guaranteed!
Download 2018 EnsurePass 1z0-804 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

Leave a Comment

(0 Comments)

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