Best Quality of 1Z0-804 exam price materials and pack for Oracle certification for IT examinee, Real Success Guaranteed with Updated 1Z0-804 pdf dumps vce Materials. 100% PASS Java SE 7 Programmer II Exam exam Today!

2016 Jun 1Z0-804 Study Guide Questions:

Q51. Assuming the port statements are correct, which two (three?) code fragments create a one-byte file? 

A. OutputStream fos = new FileOutputStream(new File("/tmp/data.bin")); OutputStream bos = new BufferedOutputStream(fos); DataOutputStream dos = new DataOutputStream(bos); dos.writeByte(0); dos.close(); 

B. OutputStream fos = new FileOutputStream ("/tmp/data.bin"); 

DataOutputStream dos = new DataOutputStream(fos); 

dos.writeByte(0); 

dos.close(); 

C. OutputStream fos = new FileOutputStream (new File ("/tmp/data.bin")); 

DataOutputStream dos = new DataOutputStream(fos); 

dos.writeByte(0); 

dos.close(); 

D. OutputStream fos = new FileOutputStream ("/tmp/data.bin"); fos.writeByte(0); 

fos.close(); 

Answer: A,B,C 

Explanation: 

B:Create DataOutputStream from FileOutputStream public static void main(String[] args) 

throws 

Exception { FileOutputStream fos = new FileOutputS tream("C:/demo.txt"); 

DataOutputStream dos = new 

DataOutputStream(fos); 

Note: 

The FileOutputStream class is a subclass of OutputStream. You can construct a 

FileOutputStream object by 

passing a string containing a path name or a File object. 

You can also specify whether you want to append the output to an existing file. 

public FileOutputStream (String path) 

public FileOutputStream (String path, boolean append) 

public FileOutputStream (File file) 

public FileOutputStream (File file, boolean append) 

With the first and third constructors, if a file by the specified name already exists, the file 

will be overwritten. Toappend to an existing file, pass true to the second or fourth 

constructor. 

Note 2:public class DataOutputStreamextends FilterOutputStreamimplements DataOutput 

A data output stream lets an application write primitive Java data types to an output stream 

in a portable way. 

An application can then use a data input stream to read the data back in. 

Reference:java.io Class DataOutputStream 


Q52. Given that myfile.txt contains: 

What is the result? 

A. new file.txt contains: 

1: First 

2: Second 

3:

 Third 

B. 

new file.txt contains: 

1:

 First 2: Second 3: Third 

C. 

newfile.txt is empty 

D. 

an exception is thrown at runtime 

E. 

compilation fails 

Answer: A 

Explanation: 

For each line in the file myfile.text the line number and the line is written into newfile.txt. 


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

A. A new Thread is used for each task. 

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

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

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

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

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


certifyforall.com

Rebirth java 1z0-804 book:

Q54. Which concept allows generic collections to interoperate with java code that defines collections that use rawtypes? 

A. bytecode manipulation 

B. casting 

C. autoboxing 

D. auto-unboxing 

E. type erasure 

Answer: E 

Explanation: 

The type erasure of its leftmost bound, or type Object if no bound was specified. Examples: type parameters type erasure List<String> List Map.Entry<String,Long> Map.Entry <T extends Cloneable & Comparable<T>> Cloneable <T extends Object & Comparable<T>> Object 

<T> T[] toArray(T[] a) Object[] toArray(Object[] a) 

The type erasure process can be imagined as a translation from generic Java source code 

back into regularJava code. In reality the compiler is more efficient and translates directly to 

Java byte code. But the byte codecreated is equivalent to the non-generic Java code. 


Q55. Given: 

Which two classes correctly override the getDepth method? 

A. public class deep extends Deeper { 

protected Integer getDepth(){ 

return 5; 

}} 

B. public class deep extends Deeper { 

public Double getDepth() { 

return 5d; 

}} 

C. public class deep extends Deeper { 

public String getDepth () { 

}} 

D. public class deep extends Deeper { 

public Long getDepth (int d) { 

return 5L; 

}} 

E. public class deep extends Deeper { 

public Short getDepth () { 

return 5; 

}} 

Answer: A,E 

Explanation: 

Note: The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short. 

Subclasses of Number must provide methods to convert the represented numeric value to byte, double, float, int, long, and short. 

When class C extends B, we say that C is a "subclass" of B, and B is the "superclass" of C. This is called inheritence, because C inherited from B. 


Q56. Given the following code fragment: 

What is the result? 

A. Three 

B. One 

C. Compilation fails 

D. The program runs, but prints no outout 

Answer: B 

Explanation: 

add boolean add(E e) Inserts the specified element into the queue represented by this deque (in other words, at the tail of thisdeque) if it is possible to do so immediately without violating capacity restrictions, returning true uponsuccess and throwing an IllegalStateException if no space is currently available. When using acapacity-restricted deque, it is generally preferable to use offer. This method is equivalent to addLast(E). remove E remove() Retrieves and removes the head of the queue represented by this deque (in other words, the first element ofThisdeque). This method differs from poll only in that it throws an exception if this deque is empty. This method is equivalent to removeFirst(). Returns: Thehead of the queue represented by this deque Class ArrayDeque 


1Z0-804  exam price

Certified 1z0-804 sample questions:

Q57. Given: And the commands: 

javac Test.java 

java ea Test 

What is the result? 

A. Compilation fails 

B. Standard Edition Enterprise Edition Micro Edition 

C. Standard Edition class java.lang.AssertionError Micro Edition 

D. Standard Edition is printed and an Assertion Error is thrown 

Answer: D 

Explanation: 

javac Test.java 

will compile the program. 

As for command line: 

java ea Test 

First the code will produce the output: 

Standard Edition 

See Note below. 

The ea option will enable assertions. This will make the following line in the switch 

statement to be run: 

default: assert false; 

This will throw an assertion error. This error will be caught. An the class of the assertion 

error (classjava.lang.AssertionError) will be printed by the following line: 

System.out.println(e.getClass()); 

Note:The java tool launches a Java application. It does this by starting a Java runtime 

environment, loading aspecified class, and invoking that class's main method. The method 

declaration must look like the following: 

public static void main(String args[]) 

Paramater ea: 

-enableassertions[:<package name>"..." | :<class name> ] -ea[:<package name>"..." | 

:<class name> ] 

Enable assertions. Assertions are disabled by default. With no arguments, 

enableassertions or -ea enablesassertions. 

Note 2: 

An assertion is a statement in the JavaTM programming language that enables you to test 

your assumptionsabout your program. 

Each assertion contains a boolean expression that you believe will be true when the 

assertion executes. If it isnot true, the system will throw an error. 

public class AssertionError extends Error 

Thrown to indicate that an assertion has failed. 

Note 3: 

The javac command compiles Java source code into Java bytecodes. You then use the 

Java interpreter - the 

java command - to interprete the Java bytecodes. 

Reference:java - the Java application launcher 

Reference:java.langClass AssertionError 


Q58. Given the code fragment: 

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. 

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 


Q59. Given the code fragment: 

DateFormat df; 

Which statement defines a new Dateformat object that displays the default date format for the UK Locale? 

A. df = DateFormat.getDateInstance (DateFormat.DEFAULT, Locale (UK)); 

B. df = DateFormat.getDateInstance (DateFormat.DEFAULT, UK); 

C. df = DateFormat.getDateInstance (DateFormat.DEFAULT, Locale.UK); 

D. df = new DateFormat.getDateInstance (DateFormat.DEFAULT, Locale.UK); 

E. df = new DateFormat.getDateInstance (DateFormat.DEFAULT, Locale (UK)); 

Answer: C 

Explanation: 

The UK locale is constructed withLocale.UK. 

To format a date for a different Locale, specify it in the call to getDateInstance(). 

DateFormat df = 

DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE); 

Note: getDateInstance( int style, Locale aLocale ) 

Gets the date formatter with the given formatting style for the given locale. 

Reference:Class DateFormat 


Q60. Given: 

What is the result? 

A. Compilation succeeds. 

B. Compilation fails due to an error on line 1. 

C. Compilation fails due to an error on line 2. 

D. Compilation fails due to an error on line 3. 

E. Compilation fails due to an error on line 4. 

F. Compilation fails due to an error on line 8. 

Answer: A