We provide real 1Z0-804 exam questions and answers braindumps in two formats. Download PDF & Practice Tests. Pass Oracle 1Z0-804 Exam quickly & easily. The 1Z0-804 PDF type is available for reading and printing. You can print more and practice many times. With the help of our Oracle 1Z0-804 dumps pdf and vce product and material, you can easily pass the 1Z0-804 exam.

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


Q22. Which four are true about enums? 

A. An enum is typesafe. 

B. An enum cannot have public methods or fields. 

C. An enum can declare a private constructor. 

D. All enums implicitly implement Comparable. 

E. An enum can subclass another enum. 

F. An enum can implement an interface. 

Answer: A,C,D,F Explanation: 

C: The constructor for an enum type must be package-private or private access. Reference: Java Tutorials,Enum Types 


Q23. Given: 

Which two statements are true about the writer class? 

A. It compiles without any changes. 

B. It compiles if the code void write (String s); is added at line***. 

C. It compiles if the code void write (); is added at line ***. 

D. It compiles if the code void write (string s) { } is added at line ***. 

E. It compiles if the code write () {}is added at line ***. 

Answer:

Explanation: 

An abstract class does not need to implement the interface methods. 


Q24. Given: 

What is the most likely result? 

A. Main One Two 

B. Main Two One 

C. One Two Main 

D. One Main Two 

E. Two Main One 

Answer:


Q25. Given the code fragment: 

What change should you make to apply good coding practices to this fragment? 

A. Add nested try-with-resources statements for the statement and ResultSet declarations. 

B. Add the statement and ResultSet declarations to the try-with-resources statement. 

C. Add a finally clause after the catch clause. 

D. Rethrow SQLException. 

Answer:

Explanation: 

The finally block always executes when the try block exits. This ensures that the finally block is executed evenif an unexpected exception occurs. But finally is useful for more than just exception handling -- it allows theprogrammer to avoid having cleanup code accidentally bypassed by a return, continue, or break.Putting cleanup code in a finally block is always a good practice, even when no exceptions areanticipated. 


Q26. Given: 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 

Answer:


Q27. Which type of ExecutorService supports the execution of tasks after a fixed delay? 

A. DelayedExecutorService 

B. ScheduledExecutorService 

C. TimedExecutorService D. FixedExecutorService 

E. FutureExecutorService 

Answer:

Explanation: 

The ScheduledExecutorService interface supplements the methods of its parent 

ExecutorService withschedule, which executes a Runnable or Callable task after a 

specified delay. In addition, the interface definesscheduleAtFixedRate and 

scheduleWithFixedDelay, which executes specified tasks repeatedly, at definedintervals. 

Note:The java.util.concurrent package defines three executor interfaces: 

*Executor, a simple interface that supports launching new tasks. *ExecutorService, a 

subinterface of Executor,which adds features that help manage the lifecycle, both of the 

individual tasks and of the executor itself. 

*ScheduledExecutorService, a subinterface of ExecutorService, supports future and/or 

periodic execution oftasks. 

Reference: The Java Tutorials,Executor Interfaces 


Q28. Given the class? 

What is the result? 

A. Jane Doe John Doe Joe Shmoe 

B. John Doe Jane Doe Joe Shmoe 

C. Joe Shmoe John Doe Jane Doe 

D. Joe Shmoe Jane Doe John Doe 

E. Jane Doe Joe Shmoe John Doe 

F. John Doe Joe Shmoe Jane Doe 

Answer:

Explanation: The list will be sorted alphabetically (Lastname / Firstname). first sorted by Lastname if Lastname equals, sorted by firstname Output will be: Jane Doe John Doe Joe Shmoe 


Q29. Given the incomplete pseudo-code for a fork/join framework application: 

And given the missing methods: Process, submit, and splitInHalf Which three insertions properly complete the pseudo-code? 

A. Insert submit at line X. 

B. Insert splitInHalf at line X. 

C. Insert process at line X. 

D. Insert process at line Y. 

E. Insert splitInHalf at line Y. 

F. Insert process at line Z. 

G. Insert submit at line Z. 

Answer: C,E,G 

Explanation: 

C: If data is small enough then process it. Line X 

E: If data is not small enough then split it half. Line Y 

G: After the data has been split (line Y) then recursively submit the splitted data (Line z). 


Q30. The two methods of code reuse that aggregate the features located in multiple classes are ____________ ? 

A. Inheritance 

B. Copy and Paste 

C. Composition 

D. Refactoring 

E. Virtual Method Invocation 

Answer: A,C 

Explanation: 

A: Inheritance is a way of reusing code and building bigger more functional objects from a 

basic object. 

The original little object, the parent, is called the super-class. The more functional object 

that inherits from it iscalled the sub-class . 

C: When your goal is code reuse, composition provides an approach that yields easier-to-change code.