10 Tips For 1Z0-804 examinee

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.

♥♥ 2021 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

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



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. 

Q42. 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; 




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) 

Q43. Given the code fragment: 

Which two try statements, when inserted at line ***, enable the code to successfully move the file info.txt to thedestination directory, even if a file by the same name already exists in the destination directory? 

A. try (FileChannel in = new FileInputStream (source). getChannel(); FileChannel out = 

new FileOutputStream 

(dest).getChannel()) { in.transferTo(0, in.size(), out); 

B. try ( Files.copy(Paths.get(source),Paths.get(dest)); 

Files.delete (Paths.get(source)); 

C. try ( Files.copy(Paths.get(source), 

Paths.get(dest),StandardCopyOption.REPLACE_EXISTING); Files.delete 


D. try (Files.move(Paths.get(source),Paths.get(dest)); 

E. try(BufferedReader br = Files.newBufferedReader(Paths.get(source), 

Charset.forName("UTF- 8")); 

BufferedWriter bw = Files.newBufferedWriter(Paths.get(dest), Charset.forName("UTF-8")); 

String record = 


while ((record = br.readLine()) ! = null) { 




Answer: C,E 


A: copies only, don’t move operation 

B,C,D (no try-with-resource !) syntax change to: try { … 

B: throws FileAlreadyExistsException 

C: correct if syntax change to : StandardCopyOption.REPLACE_EXISTING (before 


D: throws FileAlreadyExistsException 

E: works properly if the sourcefile has the correct format, utf-8 here (else throws 


AND syntax is corrected to: 

try ( BufferedReader br = Files.newBufferedReader(Paths.get(source), 


BufferedWriter bw = Files.newBufferedWriter(Paths.get(dest), Charset.forName(“UTF-8)); 


String record = “”; 


Q44. Given: What is the result? 

A. 1 

B. 0 

C. 2 

D. Compilation fails 

E. An exception is thrown at runtime 


Explanation: Section: (none) 


The code compiles fine. 


because only one element of list is initialized : element [0] 

elements [1] and [2] equals null 

alte Begründung: 

An exception is thrown at runtime due to data type comparison mismatch: 

Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast 

to java.lang.Integer 

at java.lang.Integer.compareTo(Integer.java:52) 

at java.util.Arrays.binarySearch0(Arrays.java:1481) 

at java.util.Arrays.binarySearch(Arrays.java:1423) 

at searchtext.SearchText.main(SearchText.java:22) 


public static int binarySearch(char[] a, 

char key)Searches the specified array of chars for the specified value using the binary 

search algorithm. The array mustbe sorted (as by the sort method, above) prior to making 

this call. If it is not sorted, the results are undefined. Ifthe array contains multiple elements 

with the specified value, there is no guarantee which one will be found. 


a - the array to be searched. 

key - the value to be searched for. 


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

insertionpoint is defined as the point at which the key would be inserted into the list: the 

index of the first elementgreater than the key, or list.size(), if all elements in the list are less 

than the specified key. Note that thisguarantees that the return value will be >= 0 if and 

only if the key is found. 

Q45. Which statement creates a low overhead, low-contention random number generator that is isolated to thread togenerate a random number between 1 and 100? 

A. int i = ThreadLocalRandom.current().nextInt(1, 101); 

B. int i = ThreadSafeRandom.current().nextInt(1, 101); 

C. int i = (int) Math.random()*100+1; 

D. int i = (int) Math.random(1, 101); 

E. int i = new random().nextInt(100)+1; 



public class ThreadLocalRandom extends Random A random number generator isolated to the current thread. Like the global Random generator used by the Mathclass, a ThreadLocalRandom is initialized with an internally generated seed that may not otherwise bemodified. When applicable, use of ThreadLocalRandom rather than shared Random objects in concurrentprograms will typically encounter much less overhead and contention. Use of ThreadLocalRandom isparticularly appropriate when multiple tasks (for example, each a ForkJoinTask) use random numbers inparallel in thread pools. Usages of this class should typically be of the form: ThreadLocalRandom.current().nextX(...) (where X is Int, Long, etc). When all usages are of this form, it is never possible to accidently share a ThreadLocalRandom across multiple threads. 

This class also provides additional commonly used bounded random generation methods. Reference:Class ThreadLocalRandom 

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


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. 

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



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. 

Q48. You have been asked to create a ResourceBundle file to localize an application. 

Which code example specifies valid keys menu1 and menu2 with values of File Menu and View Menu? 

A. <key name ="menu1">File Menu</key> <key name ="menu1">View Menu</key> 

B. <key> menu1</key><File Menu>File Menu </value> <key> menu1</key><File Menu>View Menu </value> 

C. menu1m File menu, menu2, view menu 

D. menu1 = File Menu menu2 = View Menu 



A properties file is a simple text file. You can create and maintain a properties file with just aboutany text editor. 

You should always create a default properties file. The name of this file begins with the base name of your ResourceBundle and ends with the .properties suffix. In the PropertiesDemo program the base name is LabelsBundle. Therefore the default properties file is called LabelsBundle.properties. The following examplefilecontains the following lines: # This is the default LabelsBundle.properties file s1 = computer s2 = disk s3 = monitor s4 = keyboard Note that in the preceding file the comment lines begin with a pound sign (#). The other lines contain key-valuepairs. The key is on the left side of the equal sign and the value is on the right. For instance, s2 is the key thatcorresponds to the value disk. The key is arbitrary. We could have called s2 something else, like msg5 ordiskID. Once defined, however, the key should not change because it is referenced in the source code. Thevalues may be changed. In fact, when your localizers create new properties files to accommodate additionallanguages, they will translate the values into various languages. 

Q49. Given the code fragment: 

And a DOS-based file system: 

Which option, containing statement(s), inserted at line 3, creates the file and sets its attributes to hidden andread-only? 

A. DOSFileAttributes attrs = Files.setAttribute(file,"dos:hidden","dos: readonly") Files.createFile(file, attrs) 

B. Files.craeteFile(file); Files.setAttribute(file,"dos:hidden","dos:readonly"); 

C. Files.createFile(file,"dos:hidden","dos:readonly"); 

D. Files.createFile(file); Files.setAttribute(file,"dos:hidden", true); Files.setAttribute(file,"dos:readonly", true); 



You can set a DOS attribute using the setAttribute(Path, String, Object, LinkOption...) 

method, as 


Path file = ...; 

Files.setAttribute(file, "dos:hidden", true); 



public static Path setAttribute(Path path, 

String attribute, 

Object value, 

LinkOption... options) 

throws IOException 

Sets the value of a file attribute. 

Reference:Interface DosFileAttribute 

Q50. Given the following code fragment: 

What is the result? 

A. Three 

B. One 

C. Compilation fails 

D. The program runs, but prints no outout 



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