Exam Code: 1Z0-804 (Practice Exam Latest Test Questions VCE PDF)
Exam Name: Java SE 7 Programmer II Exam
Certification Provider: Oracle
Free Today! Guaranteed Training- Pass 1Z0-804 Exam.


♥♥ 2018 NEW RECOMMEND ♥♥

Free VCE & PDF File for Oracle 1Z0-804 Real Exam (Full Version!)

★ Pass on Your First TRY ★ 100% Money Back Guarantee ★ Realistic Practice Exam Questions

Free Instant Download NEW 1Z0-804 Exam Dumps (PDF & VCE):
Available on: http://www.surepassexam.com/1Z0-804-exam-dumps.html

Q1. Given the integer implements comparable: 

What is the result? 

A. 4 1 

B. 1 2 

C. 32 

D. 21 

E. 2 3 

Answer:

Explanation: 

binarySearch 

public static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key) 

Searches the specified list for the specified object using the binary search algorithm. 

The list must be sorted into ascending order according to the natural ordering of its 

elements (as by the sort(List) method) prior to making this call. If it is not sorted, the results 

are undefined. 

Parameters: 

list - the list to be searched. 

key - the key to be searched for. 

Returns: 

the index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1). 


Q2. Given: What is the result? 

A. doc 

B. index.html 

C. an IllegalArgumentException is thrown at runtime. 

D. An InvalidPthException is thrown at runtime. 

E. Compilation fails. 

Answer:

Explanation: 

p.getName(int location) = returns path' name element by index/location (starts with 0) 

Example: 

path = "project//doc//index.html" 

p.getName(0) = project 

p.getName(1) = doc 

p.getName(2) = index.html 


Q3. Given the code fragment: 

Which three are true? 

A. On line 3, the current thread stops and waits until the t1 thread finishes. 

B. On line 3, the t1 thread stops and waits until the current thread finishes. 

C. On line 4, the t1 thread is dead. 

D. On line 4, the t1 thread is waiting to run. 

E. This code cannot throw a checked exception. 

F. This code may throw a checked exception. 

Answer: A,C,F 

Explanation: 

Thejoin()methods waits for this thread to die. 


Q4. Given: Which two are true? 

A. A runtime exception is thrown on line 9. 

B. No output is produced. 

C. Greeting is printed once. 

D. Greeting is printed twice. 

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

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

G. Two new threads of execution are started within the main method. 

Answer: C,E 

Explanation: 

Thread t2 is executed. Execution of T2 starts executionen of t1. Greeting is printed during theexecution of t1. 


Q5. 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(); 

Answer:

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 


Q6. 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:

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 


Q7. Given: What is the result? 

A. Three 

B. One 

C. Compilation fails. 

D. The program runs, but prints no output. 

Answer:

Explanation: 

push 

void push(E e) 

Pushes an element onto the stack represented by this deque (in other words, at the head 

of this deque) if it ispossible to do so immediately without violating capacity restrictions, 

returning true upon success and throwingan IllegalStateException if no space is currently 

available. 

This method is equivalent to addFirst(E). 

pop 

E pop() 

Pops an element from the stack represented by this deque. In other words, removes and 

returns the firstelement of this deque. 

This method is equivalent to removeFirst(). 

Returns: 

the element at the front of this deque (which is the top of the stack represented by this 

deque) 

Throws: 

NoSuchElementException - if this deque is empty 


Q8. 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:


Q9. Which two forms of abstraction can a programmer use in Java? 

A. enums 

B. interfaces 

C. primitives 

D. abstract classes 

E. concrete classes 

F. primitive wrappers 

Answer: B,D 

Explanation: 

When To Use Interfaces An interface allows somebody to start from scratch to implement your interface or implement your interface insome other code whose original or primary purpose was quite different from your interface. To them, yourinterface is only incidental, something that have to add on to thetheir code to be able to use your package. Thedisadvantage is every method in the interface must be public. You might not want to expose everything. 

*When To Use Abstract classes An abstract class, in contrast, provides more structure. It usually defines some default implementations andprovides some tools useful for a full implementation. The catch is, code using it must use your class as thebase. That may be highly inconvenient if the other programmers wanting to use your package have alreadydeveloped their own class hierarchy independently. In Java, a class can inherit from only one base class.*When to Use Both You can offer the best of both worlds, an interface and an abstract class. Implementors can ignore yourabstract class if they choose. The only drawback of doing that is calling methods via their interface name isslightly slower than calling them via their abstract class name. 

Reference:http://mindprod.com/jgloss/interfacevsabstract.html 


Q10. Given: 

What is the result? 

A. Event Quiz 

B. Event Event 

C. Quiz Quiz 

D. Quiz Event 

E. Compilation fails 

Answer: