Oracle 1Z0-804 Free Practice Questions 2021

Cause all that matters here is passing exam with . Cause all that you need is a high score of . The only one thing you need to do is downloading free now. We will not let you down with our money-back guarantee.

Check 1Z0-804 free dumps before getting the full version:

Which two codes correctly represent a standard language locale code?

  • A. ES
  • B. FR
  • C. U8
  • D. Es
  • E. fr
  • F. u8

Answer: AB

Explanation: Language codes are defined by ISO 639, an international standard that assigns two- and three-letter codes tomost languages of the world. Locale uses the two-letter codes to identify the target language.

1Z0-804 dumps exhibit
Which statement will iterate through Direction?

  • A. for (Direction d : Direction.values()){//}
  • B. for (Direction d : Direction.asList()){//}
  • C. for (Direction d : Direction.iterator()){//}
  • D. for (Direction d : Direction.asArray()){//}

Answer: A

Explanation: The static values() method of an enum type returns an array of the enum values. The foreach loop is a good
way to go over all of them.
//... Loop over all values.
for (Direction d : Direction.values()){ System.out.println(d); // PrintsNORTH, EAST, ...

Given the following incorrect program:
1Z0-804 dumps exhibit
Which two changes make the program work correctly?

  • A. Results must be retrieved from the newly created MyTask instances and combined.
  • B. The threshold value must be increased so that the overhead of task creation does not dominate the cost ofcomputation.
  • C. The midpoint computation must be altered so that it splits the workload in an optimal manner.
  • D. The compute () method must be changed to return an Integer result.
  • E. The compute () method must be enhanced to (fork) newly created tasks.
  • F. The myTask class must be modified to extend RecursiveAction instead of RecursiveTask

Answer: AD

Explanation: Note 1: A RecursiveTask is a recursive result-bearing ForkJoinTask.
Note 2: The invokeAll(ForkJoinTask<?>… tasks) forks the given tasks, returning when isDone holds for eachtask or an (unchecked) exception is encountered, in which case the exception is rethrown.
Note 3: Using the fork/join framework is simple. The first step is to write some code that performs a segmentof the work. Your code should look similar to this:
if (my portion of the work is small enough) do the work directly
split my work into two pieces
invoke the two pieces and wait for the results
Wrap this code as a ForkJoinTask subclass, typically as one of its more specialized types RecursiveTask
(which can return a result) or RecursiveAction.

1Z0-804 dumps exhibit
Which group of method is moved to a new class when implementing the DAO pattern?

  • A. public in getId ()public String getContractDetails ()public Void setContractDetails(String contactDetails) public String getName ()public void setName (String name)
  • B. public int getId ()public String getContractDetails() public String getName()public Person getPerson(int id) throws Exception
  • C. public void setContractDetails(String contractDetails) public void setName(String name)
  • D. public Person getPerson(int id) throws Exception public void createPerson(Person p) throws Exception public void deletePerson(int id) throws Exception public void updatePerson(Person p) throws Exception

Answer: D

Explanation: The methods related directly to the entity Person is moved to a new class. CRUD
Note:DAO Design Pattern
*Abstracts and encapsulates all access to a data source *Manages the connection to the data source to obtain
and store data *Makes the code independent of the data sources and data vendors (e.g. plain-text, xml, LDAP,
MySQL, Oracle, DB2)
1Z0-804 dumps exhibit
D:Documents and SettingsuseralboDesktop1.jpg Example (here Customer is the main entity):
public class Customer { private final String id; private String contactName; private String phone;
public void setId(String id) { = id; } public String getId() { return; }
public void setContactName(String cn) { this.contactName = cn;} public String getContactName() { return
this.contactName; } public void setPhone(String phone) { = phone; } public String getPhone()
{ return; }
public interface CustomerDAO {
public void addCustomer(Customer c) throws DataAccessException; public Customer getCustomer(String id)
throws DataAccessException; public List getCustomers() throws DataAccessException; public void
removeCustomer(String id) throws DataAccessException; public void modifyCustomer(Customer c) throws
DataAccessException; }

1Z0-804 dumps exhibit
And the commands: javac java ea Counter
What is the result?

  • A. 2
  • B. 3
  • C. NullPointException is thrown at runtime
  • D. AssertionError is thrown at runtime
  • E. Compilation fails

Answer: B

Explanation: The command line javac Willcompile the code.
The command line java ea Counter Willrun the cod with assertions enabled.
Assertion is true because getCount(arr) = 3 and Length of array is 4
The following line:
assert (getCount(arr) < arr.length);
where the Boolean expression getCount(arr) < arr.length will evaluate to false, will ensure that anAssertionError is thrown at runtime.
Note:The javac command compiles Java source code into Java bytecodes. You then use the Java interpreter -the java command - to interprete the Java bytecodes.
Note 2:The java tool launches a Java application. It does this by starting a Java runtime environment, loading aspecified class, and invoking that class's main method. The method declaration must look like the following:public static void main(String args[])
Paramater ea:
-enableassertions[:<package name>"..." | :<class name> ] -ea[:<package name>"..." |
:<class name> ]
Enable assertions. Assertions are disabled by default. With no arguments, enableassertions or -ea enablesassertions.
Note 3:
An assertion is a statement in the JavaTM programming language that enables you to test your assumptionsabout your program.
Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it isnot true, the system will throw an error.

Given the two Java classes:
1Z0-804 dumps exhibit
Which two code snippets, added independently at line ***, can make the Buzzword class compile?

  • A. this ();
  • B. this (100);
  • C. this ("Buzzword");
  • D. super ();
  • E. super (100);
  • F. super ("Buzzword");

Answer: CF

Select four examples that initialize a NumberFormat reference using a factory.

  • A. NumberFormat nf1 = new DecimalFormat();
  • B. NumberFormat nf2 = new DecimalFormat("0.00") ;
  • C. NumberFormat nf3 = NumberFormat.getInstance();
  • D. NumberFormat nf4 = NumberFormat.getIntegerInstance();
  • E. NumberFormat nf5 = DecimalFormat.getNumberInstance ();
  • F. NumberFormat nf6 = NumberFormat.getCurrencyInstance () ;

Answer: CDEF

Explanation: getInstance
public static finalNumberFormatgetInstance()
Returns the default number format for the current default locale. The default format is one of the styles
provided by the other factory methods: getNumberInstance(E), getIntegerInstance(D), getCurrencyInstance(F)
or getPercentInstance. Exactly which one is locale dependant.
C: To obtain a NumberFormat for a specific locale, including the default locale, call one of NumberFormat'sfactory methods, such as getInstance().
E:To obtain standard formats for a given locale, use the factory methods on NumberFormat such asgetNumberInstance. These factories will return the most appropriate sub-class of NumberFormat for a givenlocale.
F:To obtain standard formats for a given locale, use the factory methods on NumberFormat such asgetInstance or getCurrencyInstance.
Reference:java.textClass NumberFormat

Given the following code fragment:
:10. p1 = paths.get("report.txt");
:11. p2 = paths.get("company");
:12. / / insert code here
Which code fragment, when inserted independently at line 12, move the report.txt file to the company directory,at the same level, replacing the file if it already exists?

  • A. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
  • B. Files.move(p1, p2, StandardCopyOption.REPLACE_Existing, LinkOption.NOFOLLOW_LINKS);
  • C. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS);
  • D. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.copy_ATTRIBUTES,StandrardCopyOp)
  • E. Files.move (p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.copy_ATTRIBUTES,LinkOption.NOF)

Answer: AC

Explanation: Moving a file is equally as straight forward
move(Path source, Path target, CopyOption... options); The available StandardCopyOptions enums available are: StandardCopyOption.REPLACE_EXISTING StandardCopyOption.ATOMIC_MOVE
If Files.move is called with StandardCopyOption.COPY_ATTRIBUTES an UnsupportedOperationException isthrown.

Given a language code of fr and a country code of FR, which file name represents a resource bundle file namethat is not the default?

  • A.
  • B. MessageBundle_fr_FR.profile
  • C. MessageBundle_fr_FR.xinl
  • D. MessageBundle fr FR.Java
  • E. MessageBundle fr FR.Locale

Answer: A

Explanation: The default file is The non-default file name is
Note is a file extension for files mainly used in Java related technologies to store the configurableparameters of an application. They can also be used for storing strings for Internationalization and localization;these are known as Property Resource Bundles. Each parameter is stored as a pair of strings, one storing thename of the parameter (called the key), and the other storing the value.Note 1:You can obtain an instance of ResourceBundle by calling its static getBundle method.public static ResourceBundle getBundle(java.lang.String baseName) public static ResourceBundle getBundle(java.lang.String baseName, Locale locale) For example:
ResourceBundle rb = ResourceBundle.getBundle("MyResources", Locale.US); This will load theResourceBundle object with the values in the corresponding properties file.1.If a suitable properties file is not found, the ResourceBundle object will use the default properties file, whichwill be the one whose name equals the base name and has the properties extension. In this case, the defaultfile would be 2.If this file is not found, a java.util.MissingResourceException will bethrown.
Note2:java.util.ResourceBundle class enables you to choose and read the properties file specific to the user'slocale and look up the values.
A ResourceBundle object has a base name. In order for a ResourceBundle object to pick up a properties file,the filename must be composed of the ResourceBundle base name, followed by an underscore, followed bythe language code, and optionally followed by another underscore and the country code.
The format for the properties file name is as follows: basename_languageCode_countryCode
For example, suppose the base name is MyResources and you define the following three locales:
US-en DE-de CN-zh
Then you would have these three properties files:
Reference:Reading Properties Files using ResourceBundle

Which two demonstrate the valid usage of the keyword synchronized?

  • A. interface ThreadSafe { synchronized void doIt();}
  • B. abstract class ThreadSafe { synchronized abstract void doIt();}
  • C. class ThreadSafe { synchronized static void soIt () {}}
  • D. enum ThreadSafe { ONE, TWO, Three;synchronized final void doIt () {}}

Answer: C

Explanation: The Java programming language provides two basic synchronization idioms: synchronized methods and synchronized statements.
To make a method synchronized, simply add the synchronized keyword to its declaration.

1Z0-804 dumps exhibit
Which two statements, inserted independently at line ***, enable the program to produce the following output:
We have 002 Blue pants that cost $24.99.

  • A. System.out.printf("We have %03d %s pants that cost $%3.2f.n",quantity, color, price);
  • B. System.out.printf("We have$03d$s pants that cost $$3.2f.n",quantity, color, price);
  • C. String out = String.format ("We have %03d %s pants that cost $%3.2f.n",quantity, color,price);System.out.println(out);
  • D. String out = System.out.format("We have %03d %s pants that cost $%3.2f.",quantity, color, price);System.out.println(out);
  • E. System.out.format("We have %s%spants that cost $%s.n",quantity, color, price);

Answer: AC

1Z0-804 dumps exhibit
Which is correct?

  • A. Employee takes advantage of composition.
  • B. Employee "has-an" Email.
  • C. Employee "is-a" LetterPrinter.
  • D. Employee has low cohesion.

Answer: D

Explanation: The relationship between Employee and e-mail is poorly implemented here. There is low cohesion.
Low cohesion is associated with undesirable traits such as being difficult to maintain, difficult to test, difficult toreuse, and even difficult to understand.
Cohesion is decreased if:
The functionalities embedded in a class, accessed through its methods, have little in common. Methods carryout many varied activities, often using coarsely-grained or unrelated sets of data. Disadvantages of lowcohesion (or"weak cohesion") are: Increased difficulty in understanding modules.
Increased difficulty in maintaining a system, because logical changes in the domain affect multiple modules,and because changes in one module require changes in related modules. Increased difficulty in reusing amodule because most applications won't need the random set of operations provided by a module.Reference:Cohesion (computer science)

1Z0-804 dumps exhibit
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: B

Given the code fragment:
1Z0-804 dumps exhibit
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);

Answer: D

Explanation: You can set a DOS attribute using the setAttribute(Path, String, Object, LinkOption...) method, as
Path file = ...;
Files.setAttribute(file, "dos:hidden", true); Note:
public static Path setAttribute(Path path, String attribute,
Object value, LinkOption... options) throws IOException
Sets the value of a file attribute. Reference:Interface DosFileAttribute

1Z0-804 dumps exhibit
What is the result?

  • A. woof arf
  • B. woof woof
  • C. arf arf
  • D. A RuntimeException is generated
  • E. The code fails to compile

Answer: E

Explanation: class Dog {
protected String bark()
public class Beagle extends Dog { private String bark()
Cannot reduce the visibility of the inherited method from Dog

Which four are syntactically correct?

  • A. package abc; package def; import Java.util . * ; public class Test { }
  • B. package abc; import Java.util.*;import Java.util.regex.* ; public class Test { }
  • C. package abc; public class Test {} import Java.util.* ;
  • D. import Java.util.*; package abc;public class Test {}
  • E. package abc; import java.uti
  • F. *; public class Test{}
  • G. public class Test{} package abc;import java.util.*{}
  • H. import java.util.*; public class Test{}
  • I. package abc; public class test {}

Answer: BEGH

Given the code fragment:
1Z0-804 dumps exhibit
Which code fragment inserted at line ***, enables the code to compile?

  • A. public void process () throws FileNotFoundException, IOException { super.process (); while ((record = br.readLine()) !=null) {System.out.println(record);}}
  • B. public void process () throws IOException { super.process ();while ((record = br.readLine()) != null) { System.out.println(record);}}
  • C. public void process () throws Exception { super.process ();while ((record = br.readLine()) !=null) { System.out.println(record);}}
  • D. public void process (){ try {super.process ();while ((record = br.readLine()) !=null) { System.out.println(record);}} catch (IOException | FileNotFoundException e) { }}
  • E. public void process (){try { super.process ();while ((record = br.readLine()) !=null) { System.out.println(record);}} catch (IOException e) {}}

Answer: E

Explanation: A: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()
B: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()
C: Compilation fails: Exception Exception is not compatible with throws clause in Base.process()
D: Compilation fails: Exception FileNotFoundException has already been caught by the alternative IOException
Alternatives in a multi-catch statement cannot be related to subclassing Alternative is a subclass of alternative
E: compiles ...

1Z0-804 dumps exhibit
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

Explanation: 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).
E pollLast()
Retrieves and removes the last element of this deque, or returns null if this deque is empty. Returns:
the tail of this deque, or null if this deque is empty

1Z0-804 dumps exhibit
What is the result?

  • A. Both const and inner will be in the output.
  • B. Only const will be in the output.
  • C. Compilation fails due to an error on line A.
  • D. Compilation fails due to an error on line B.
  • E. An Exception is thrown at runtime.

Answer: A

Explanation: The code compiles fine.
Note:The Runnable interface should be implemented by any class whose instances are intended to beexecuted by a thread. The class must define a method of no arguments called run.
This interface is designed to provide a common protocol for objects that wish to execute code while they areactive. For example, Runnable is implemented by class Thread. Being active simply means that a thread hasbeen started and has not yet been stopped.
In addition, Runnable provides the means for a class to be active while not subclassing Thread. Aclass that implements Runnable can run without subclassing Thread by instantiating a Thread instance andpassing itself in as the target. In most cases, the
Runnable interface should be used if you are only planning tooverride the run() method and no other Thread methods. This is important because classes should not besubclassed unless the programmer intends on modifying or enhancing the fundamental behavior of the class.
Note 2:start()
Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
Interface Runnable

1Z0-804 dumps exhibit
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

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

Thanks for reading the newest 1Z0-804 exam dumps! We recommend you to try the PREMIUM Surepassexam 1Z0-804 dumps in VCE and PDF here: (150 Q&As Dumps)