Approved of 1Z0-804 free exam questions materials and rapidshare for Oracle certification for IT learners, Real Success Guaranteed with Updated 1Z0-804 pdf dumps vce Materials. 100% PASS Java SE 7 Programmer II Exam exam Today!

2021 Apr 1Z0-804 Study Guide Questions:

Q91. Given the interface: 

Public interface Idgenerator { 

int getNextId(); 

Which class implements IdGenerator in a thread-safe manner, so that no threads can get a duplicate id valuecurrent access? 

A. Public class generator Implements IdGenerator { 

Private AtomicInteger id = new AtomicInteger (0); 

return id.incrementAndget(); 


B. Public class Generator Implements idGenerator { 

private int id = 0; 

return ++id; }} 

C. Public class Generator Implements IdGenerator { 

private volatile int Id = 0; 

return ++Id; 

D. Public class Generator Implements IdGenerator { 

private int id = 0; 

public int getNextId() { 

synchronized (new Generator()) { 

return ++id; 


E. Public class Generator Implements IdGenerator { 

private int id = 0; 

public int getnextId() { 

synchronized (id) { 

return ++id; 


Answer: D 


Code that is safe to call by multiple threads simultaneously is called thread safe. If a piece of code is threadsafe, then it contains no race conditions. Race condition only occur when multiple threads update sharedresources. Therefore it is important to know what resources Java threads share when executing. 

In Java you can mark a method or a block of code as synchronized. Synchronized blocks can be used to avoidrace conditions. 

A, B, C : false: wrong Implementation ( missing int getNextId(); ) 

E: false: synchronized (mutex Object! not Simple Data Type) 

Q92. Given the database table: 

And given this class: 

Assume that the SQL integer queries are valid. What is the result of compiling and executing this codefragment? 

A. A 

B. B 

C. C 

D. D 

E. E 

Answer: C 


The code will compile now. 

The three rows with PRICE in between 5.5 and 9.5 will be displayed. 

Q93. Given this code fragment: 

Assume that the SQL query returns records. 

What is the result? 

A. Compilation fails due to error at line 17 

B. The program prints Error 

C. The program prints each record 

D. Compilation fails at line 14 

Answer: C 

1Z0-804 test preparation

Up to the immediate present 1z0-804 price:

Q94. Given: Which of the four are valid modifications to synchronize access to the valid list between threads t1 and t2? 

A. Replace line 1 with: 

Synchronized (t2) (t1.start();) synchronized(t1) (t2.start(); ) 

korrekte Schreibweise: synchronized (t2) {t1.start();} synchronized(t1) { t2.start();} 

B. Replace Line 2 with: 

static CopyWriteArrayList<Integer> list = new CopyWriteArrayList<>(); 

korrekte Schreibweise: static CopyOnWriteArrayList<Integer> list = new 


C. Replace line 3 with: 

synchronized public static void addItem () { 

korrekte Schreibweise: synchronized public static void addItem () { 

D. Replace line 4 with: 

synchronized (list) (list.add(1);) 

korrekte Schreibweise: synchronized (list) { (list.add(1); } 

E. Replace line 5 with: 

Synchronized public void run () { 

korrekte Schreibweise: synchronized public void run () { 

F. replace line 6 with: 

Synchronized (this) {for (in i = 0, i<5000, i++) WorkPool.addItem(); } 

korrekte Schreibweise: synchronized (this) {for (int i = 0; i<500; i++) WorkPool.addItem(); } 

G. Replace line 6 with: 

synchronized (bar) {for (int i= 0; i<5000; i++) WorkPool.addItem(); } 

korrekte Schreibweise: synchronized (bar) {for (int i= 0; i<500; i++) WorkPool.addItem(); } 

Answer: B,C,D 


Away to create synchronized code is with synchronized statements. 

Unlike synchronized methods, synchronized statements must specify the object that 

provides theintrinsic lock: 

For example: 

public void addName(String name) { 

synchronized(this) { 

lastName = name; 



In this example, the addName method needs to synchronize changes to lastName and 

nameCount, but alsoneeds to avoid synchronizing invocations of other objects' methods. 

Without synchronized statements, therewould have to be a separate, unsynchronized 

method for the sole purpose of invoking nameList.add. 

Reference: The Java Tutorial,Intrinsic Locks and Synchronization 

Q95. Given: Which statement is true? 

A. SportsCar must implement methods from TurboVehicle and steerable 

B. SportsCar must override methods defined by car. 

C. SportsCar must implement methods define by convertible. 

D. Instances of car can invoke convertible methods. 

Answer: C 


To declare a class that implements an interface, you include an implements clause in the classdeclaration. By convention, the implements clause follows the extends clause, if there is one. Here are the some point that must be considered while implementing an interface (or interfaces) into a javaclass. A class implementing an interface must either implement all the methods of that interface otherwise known asthe abstract class. A class in java may extend at most one superclass because java does not allow multiple inheritance, by it mayimplement more than one interface. Multiple inheritance in java is achieved through the interfaces. When aclass implements more than one interface then implement statement requires a comma- separated list ofinterfaces to be implement by that class. 

Q96. Given: 

What is the result? 

A. An exception is thrown at runtime on line 9. 

B. An exception is thrown at runtime on line 12 

C. onetwonull 

D. onetwothree 

E. twoonenull 

F. threetwoone 

Answer: D 


addFirst void addFirst(E e) Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted deque, it is generally preferable to 

use method offerFirst 



E pollLast() 

Retrieves and removes the last element of this deque, or returns null if this deque is empty. 


the tail of this deque, or null if this deque is empty 

1Z0-804 test

Verified 1z0-804 testking:

Q97. Given: 

What is the result? 

A. 5 

B. 6 

C. An exception is thrown at runtime 

D. Compilation fails due to an error on line 6 

E. Compilation fails due to an error on line 7 

Answer: C 


The code compile fine but java.lang.NullPointerException is thrown at runtime. 

x has no value. The code would run if line 2 was changed to: 

Integer x = 3; 

Q98. Given that myfile.txt contains: 

What is the result? 

A. new file.txt contains: 

1: First 

2: Second 




new file.txt contains: 


 First 2: Second 3: Third 


newfile.txt is empty 


an exception is thrown at runtime 


compilation fails 

Answer: A 


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

Q99. Given the code fragment: What is the result, if the file myfile.txt does not exist? 

A. A runtime exception is thrown at line 4 

B. A runtime exception is thrown at line 7 

C. Creates a new file and prints no output 

D. Compilation fails 

Answer: D 


!! Compilation fails if FileNotFoundException is tried to catch (Line 12) 

(The exception FileNotFoundException is already caught by the alternative IOException) 

if this is removed will be thrown a FileNotFoundException at line 4. 

Q100. Given: 

What is the result? 

A. John-.-George-.-Paul-.-Ringo 

B. John George Paul Ringo 

C. John -George -Paul -Ringo -

D. An exception is thrown at runtime 

E. Compilation fails 

Answer: B 


The split() method is used to split a string into an array of substrings, and returns the new array. regex: - followed by two characters