[Free] Download Latest (March 2016) Oracle 1Z0-804 Real Exam 81-90

Ensurepass

QUESTION 81

Given:

 

clip_image002

 

Which two statements, inserted independently at line ***, enable the program to produce the following output:

 

We have 002 Blue pants that cost $24.99.

 

A.

System.out.printf(“We have %03d %s pants that cost $%3.2f.n”,quantity, color, price);

B.

System.out.printf(“We have$03d$s pants that cost $$3.2f.n”,quantity, color, price);

C.

String out = String.format (“We have %03d %s pants that cost $%3.2f.n”,quantity, color,price);

System.out.println(out);

D.

String out = System.out.format(“We have %03d %s pants that cost $%3.2f.”,quantity, color, price);

System.out.println(out);

E.

System.out.format(“We have %s%spants that cost $%s.n”,quantity, color, price);

 

Correct Answer: AC

 

 

QUESTION 82

Which two are true about Singletons?

 

A.

A Singleton must implement serializable.

B.

A Singleton has only the default constructor.

C.

A Singleton implements a factory method.

D.

A Singleton improves a class’s cohesion.

E.

Singletons can be designed to be thread-safe.

 

Correct Answer: CE

 

 

QUESTION 83

Given the following incorrect program:

 

clip_image004

 

Which two changes make the program work correctly?

 

A.

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

B.

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

C.

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

D.

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

E.

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

F.

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

 

Correct Answer: AD

Explanation:

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

Note 2: The invokeAll(ForkJoinTask<?>… tasks) forks the given tasks, retur
ning 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 84

Given the code fragment:

 

clip_image006

 

What is the result of the employees table has no records before the code executed?

 

A.

1 Sam

B.

4 Jack

C.

3 John

4 Jack

D.

1 Sam

3 John

4 Jack

 

Correct Answer: C

Explanation:

AutoCommit is set to false. The two following statements will be within the same transaction.

stmt.executeUpdate(“insert into employees values(1,’Sam’)”); stmt.executeUpdate(“insert into employees values(2,’Jane’)”); These two statements are rolled-back through (the savepoint is ignored! the savepoint must be specified (e.g. conn.rollback(save1); ) in the rollback if you want to rollback to the savepoint):

conn.rollback() ;

The next two insert statements are executed fine. Their result will be in the output.

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 85

Given the code fragment:

 

clip_image008

 

What is the result when the result.txt file already exists in c:student?

 

A.

The program replaces the file contents and the file’s attributes and prints Equal.

B.

The program replaces the file contents as well as the file attributes and prints Not equal.

C.

An UnsupportedOperationException is thrown at runtime.

D.

The program replaces only the file attributes and prints Not equal.

 

Correct Answer: B

Explanation:

Assuming there is a file D:\faculty\report.txt then this file will be copied and will be replacing C:\student\report.txt.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 86

Given the two Java classes:

 

clip_image010

 

Which two code snippets, added independently at line ***, can make the Buzzword class compile?

 

A.

this ();

B.

this (100);

C.

this (“Buzzword”);

D.

super ();

E.

super (100);

F.

super (“Buzzword”);

 

Correct Answer: CF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 87

Given:

 

clip_image012

 

What is the result?

 

A.

An exception is thrown at runtime on line 9.

B.

An exception is thrown at runtime on line 12

C.

onetwonull

D.

onetwothree

E.

twoonenull

F.

threetwoone

 

Correct Answer: D

Explanation:

addFirst

void addFirst(E e)

Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted deque, it is generally preferable to use method offerFirst

(E).

pollLast

E pollLast()

Retrieves and removes the last element of this deque, or returns null if this deque is empty.

Returns:

the tail of this deque, or null if this deque is empty

 

 

QUESTION 88

Given the code format:

 

SimpleDateFormat sdf;

 

Which code statements will display the full text month name?

 

A.

sdf = new SimpleDateFormat (“mm”, Locale.UK);

System.out.println(“Result:”, sdf.format(new date()));

B.

sdf = new SimpleDateFormat (“MM”, Locale.UK);

System.out.println(“Result:”, sdf.format(new date()));

C.

sdf = new SimpleDateFormat (“MMM”, Locale.UK);

System.out.println(“Result:”, sdf.format(new date()));

D.

sdf = new SimpleDateFormat (“MMMM”, Locale.UK);

System.out.println(“Result:”, sdf.format(new date()));

 

Correct Answer: D

Explanation:

Typical output would be

Current Month in M format: 2

Current Month in MM format: 02

Current Month in MMM format: Feb

Current Month in MMMM format: February

 

 

QUESTION 89

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?

 

A.

c.addAndGet();

B.

c++;

C.

c = c+1;

D.

c.getAndIncrement ();

 

Correct Answer: D

Explanation:

getAndIncrement

public final int getAndIncrement()

Atomically increment by one the current value.

Reference:java.util.concurrent.atomic

 

 

 

 

 

 

 

 

QUESTION 90

Given these facts about Java types in an application:

 

clip_image014Type x is a template for other types in the application.

clip_image014[1]Type x implements dostuff ().

clip_image014[2]Type x declares, but does NOT implement doit().

clip_image014[3]Type y declares doOther().

 

Which three are true?

 

A.

Type y must be an interface.

B.

Type x must be an abstract class.

C.

Type y must be an abstract class.

D.< /font>

Type x could implement or extend from Type y.

E.

Type x could be an abstract class or an interface.

F.

Type y could be an abstract class or an interface.

 

Correct Answer: BDF

Explanation:

Unlike interfaces, abstract classes can contain fields that are not static and final, and they can containimplemented methods. Such abstract classes are similar to interfaces, except that they provide a partialimplementation, leaving it to subclasses to complete the implementation. If an abstract class contains onlyabstract method declarations, it should be declared as an interface instead.

 

Note: An interface in the Java programming language is an abstract type that is used to specify an interface (in thegeneric sense of the term) that classes must implement. Interfaces are declaredusing the interface keyword,and may only contain method signature and constant declarations (variable declarations that are declared tobe both static and final). An interface maynever contain method definitions.

 

Note 2: an abstract class is a class that is declared abstract–it may or may not include abstract methods.Abstract classes cannot be instantiated, but they can be subclassed. An abstract method is a method that isdeclared without an implementation (without braces, and followed by a semicolon)

 

Free VCE & PDF File for Oracle 1Z0-804 Real Exam

Instant Access to Free VCE Files: CompTIA | VMware | SAP …
Instant Access to Free PDF Files: CompTIA | VMware | SAP …

 

This entry was posted in 1Z0-804 Real Exam (March 2016) and tagged , , , , , , , . Bookmark the permalink.