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

Ensurepass

QUESTION 21

Which two codes correctly represent a standard language locale code?

 

A.

ES

B.

FR

C.

U8

D.

Es

E.

fr

F.

u8

 

Correct Answer: AB

Explanation:

Language codes are defined by ISO 639, an international standard that assigns two- and three-letter codes tomost languages of the world. Locale uses the two-letter codes to identify the target language.

 

QUESTION 22

What will the following class print when run?

 

clip_image002

 

A.

javajava

B.

lavajava

C.

javajavac

D.< /font>

lavajavac

E.

None of these.

 

Correct Answer: C

 

 

QUESTION 23

Give:

 

clip_image004

 

What is the result?

 

A.

There are 27 sports cars and 5 trucks

B.

There are 27 convertibles and 5 trucks

C.

There are 9 sports cars and 5 trucks

D.

There are 9 convertibles and 5 trucks

E.

IllegalFormatConversionException is thrown at runtime

 

Correct Answer: C

Explanation:

Strings are immutable, therefore no change at line: svar.replace(svar,”convertibles”); Format String Syntax:

%[argument_index$][flags][width][.precision]conversion The optional argument_index is a decimal integer indicating the position of the argument in the argument list.

The first argument is referenced by “1$”, the second by “2$”, etc. The optional flags is a set of characters that modify the output format. The set of valid flags depends on theconversion.

‘s’, ‘S’ general

‘d’ integral The result is formatted as a decimal / integer

 

 

QUESTION 24

Given the following code fragment:

 

10. p1 = paths.get(“report.txt”);

 

11. p2 = paths.get(“company”);

 

12. / / insert code here

 

Which code fragment, when inserted independently at line 12, move the report.txt file to the company directory,at the same level, replacing the file if it already exists?

 

A.

Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);

B.

Files.move(p1, p2, StandardCopyOption.REPLACE_Existing, LinkOption.NOFOLLOW_LINKS);

C.

Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS);

D.

Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.copy_ATTRIBUTES, StandrardCopyOp)

E.

Files.move (p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.copy_ATTRIBUTES, LinkOption.NOF)

 

Correct Answer: AC

Explanation:

Moving a file is equally as straight forward

move(Path source, Path target, CopyOption… options); The available StandardCopyOptions enums available are:

StandardCopyOption.REPLACE_EXISTING

StandardCopyOption.ATOMIC_MOVE

If Files.move is called with StandardCopyOption.COPY_ATTRIBUTES an UnsupportedOperationException isthrown.

 

 

 

 

 

 

 

 

 

QUESTION 25

Given:

 

clip_image006

 

What is the result?

 

A.

1

B.

0

C.

2

D.

Compilation fails

E.

An exception is thrown at runtime

 

Correct Answer: E

Explanation:

The code compiles fine.

java.lang.NullPointerException

because only one element of list is initialized : element [0] elements [1] and [2] equals null

 

An exception is thrown at runtime due to data type comparison mismatch:

Exception in thread “main” java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer

at java.lang.Integer.compareTo(Integer.java:52)

at java.util.Arrays.binarySearch0(Arrays.java:1481) at java.util.Arrays.binarySearch(Arrays.java:1423) at searchtext.SearchText.main(SearchText.java:22)

Note: binarySearch

public static int binarySearch(char[] a, char key)Searches the specified array of chars for the specified value using the binary search algorithm. The array mustbe sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined. Ifthe array contains multiple elements with the specified value, there is no guarantee which one will be found.

Parameters:

a – the array to be searched.

key – the value to be searched for.

Returns:

Indexof the search key, if it is contained in the list; otherwise, (-(insertion point) – 1). The insertionpoint is defined as the point at which the key would be inserted into the list: the index of the first elementgreater than the key, or list.size(), if all elements in the list are less than the specified key. Note that thisguarantees that the return value will be >= 0 if and only if the key is found.

 

 

QUESTION 26

Which code fragment correctly appends “Java 7” to the end of the file /tmp/msg.txt?

 

A.

FileWriter w = new FileWriter(“/tmp/msg.txt”);

append(“Java 7”);

close();

B.

FileWriter w = new FileWriter(“/tmp/msg.txt”, true);

append(“Java 7”);

close();

C.

FileWriter w = new FileWriter(“/tmp/msg.txt”, FileWriter.MODE_APPEND);

append(“Java 7”);

close();

D.

FileWriter w = new FileWriter(“/tmp/msg.txt”, Writer.MODE_APPEND);

append(“Java 7”);

close();

 

Correct Answer: B

Explanation:

FileWriter(File file, boolean append)

A: clears the file and append “Java7”

Constructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.Parameters:

file – a File object to write toappend – if true, then bytes will be written to the end of the file rather than the beginning

 

 

QUESTION 27

Given the code fragment:

 

clip_image008

 

Assume the method printNums is passed a valid array containing data. Why is this method not producingoutput on the console?

 

A.

There is a compilation error.

B.

There is a runtime exception.

C.

The variable number is not initialized.

D.

Standard error is mapped to another destination.

 

Correct Answer: D

Explanation:

The code compiles fine.

The code runs fine.

The errorstream can be redirected.

Note:

System.out.println -> Sends the output to a standard output stream. Generally monitor. System.err.println -> Sends the output to a standard error stream. Generally monitor. err is the “standard” erroroutput stream. This stream is already open and ready to accept output data.

Typically this stream corresponds to display output or another output destination specified by the hostenvironment or user. By convention, this output stream is used to display error messages or other informationthat should come to the immediate attention of a user even if the principal output stream, the value of thevariable out, has been redirected to a file or other destination that is typically not continuously monitored.

Reference: java.lang.System

 

 

QUESTION 28

Given:

 

clip_image010

 

Which two are true?

 

A.

Thread is printed

B.

Runnable is printed

C.

No output is produced

D.

No new threads of execution are started within the main method

E.

One new thread of execution is started within the main method

F.

Two new threads of exclusion are started within the main method

 

Correct Answer: CD

 

 

QUESTION 29

Which statement declares a generic class?

 

A.

public class Example < T > { }

B.

public class <Example> { }

C.

public class Example <> { }

D.

public class Example (Generic) { }

E.

public class Example (G) { }

F.

public class Example { }

 

Correct Answer: A

Explanation:

Example:

public class Pocket<T>

{

private T value;

public Pocket() {}

public Pocket( T value ) { this.value = value; }

public void set( T value ) { this.value = value; } public T get() { return value; }

public boolean isEmpty() { return value != null; } public void empty() { value = null; }

}

 

 

QUESTION 30

Given:

 

clip_image012

 

What is the most likely result?

 

A.

size: 4, elements: 11 22 33 44

B.

size: 5, elements: 11 22 33 44

C.

size: 4, elements: 11 22 33 44 77

D.

size: 5, elements: 11 22 33 44 77

E.

a ConcurrentModification Exception is thrown

 

Correct Answer: B

 

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.