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
Q1. Given the integer implements comparable:
What is the result?
A. 4 1
B. 1 2
E. 2 3
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
list - the list to be searched.
key - the key to be searched for.
the index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1).
Q2. Given: What is the result?
C. an IllegalArgumentException is thrown at runtime.
D. An InvalidPthException is thrown at runtime.
E. Compilation fails.
p.getName(int location) = returns path' name element by index/location (starts with 0)
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.
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.
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");
B. FileWriter w = new FileWriter("/tmp/msg.txt", true);
C. FileWriter w = new FileWriter("/tmp/msg.txt", FileWriter.MODE_APPEND);
D. FileWriter w = new FileWriter("/tmp/msg.txt", Writer.MODE_APPEND);
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
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.
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?
C. Compilation fails.
D. The program runs, but prints no output.
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
This method is equivalent to addFirst(E).
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().
the element at the front of this deque (which is the top of the stack represented by this
NoSuchElementException - if this deque is empty
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.
Q9. Which two forms of abstraction can a programmer use in Java?
D. abstract classes
E. concrete classes
F. primitive wrappers
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.
What is the result?
A. Event Quiz
B. Event Event
C. Quiz Quiz
D. Quiz Event
E. Compilation fails