It is impossible to pass Oracle 1Z0-804 exam without any help in the short term. Come to Ucertify soon and find the most advanced, correct and guaranteed Oracle 1Z0-804 practice questions. You will get a surprising result by our Down to date Java SE 7 Programmer II Exam practice guides.

Q11. 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: C,D,E,F 

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 


Q12. Given: 

What is the result? 

A. Daniel 

B. Unknown 

C. It may print"unknown"or"Daniel"depending on the JVM implementation. 

D. Compilation fails. 

E. An exception is thrown at runtime. 

Answer:

Explanation: 

The compilation fails at line start(); Erstellen eines statischen Verweises auf die nicht statische Methode start() vom Typ Runner nicht m.glich.Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static method start()cannot be referenced from a static context 


Q13. Given the code fragment: 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:

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 java.io.FileNotFoundException is a subclass of alternative java.io.IOException 

E: compiles ... 


Q14. Given: 

What two changes should you make to apply the DAO pattern to this class? 

A. Make the Customer class abstract. 

B. Make the customer class an interface. 

C. Move the add, delete, find, and update methods into their own implementation class. 

D. Create an interface that defines the signatures of the add, delete, find, and update methods. 

E. Make the add, delete, and find, and update methods private for encapsulation. 

F. Make the getName and getID methods private for encapsulation. 

Answer: C,D 

Explanation: 

C:The methods related directly to the entity Customer is moved to a new class. 

D: 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) { this.id = id; } 

102 

public String getId() { return this.id; } public void setContactName(String cn) { this.contactName = cn;} public String getContactName() { return this.contactName; } public void setPhone(String phone) { this.phone = phone; } public String getPhone() { return this.phone; } } 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; } Note: DAO Design Pattern *Abstracts and encapsulates all access to a data source *Manages the connection to the data source to obtainand store data *Makes the code independent of the data sources and data vendors (e.g. plain-text, xml, LDAP, MySQL, Oracle, DB2) 

D:\Documents and Settings\useralbo\Desktop\1.jpg 


Q15. Given the code fragment: 

What is the result of the employees table has no records before the code executed? 

A. 1 Sam 

B. 4 Jack 

C. 3 John 4 Jack 

D. 1 Sam 3 John 4 Jack 

Answer:

Explanation: 

AutoCommit is set to false. The two following statements will be within the same 

transaction. 

stmt.executeUpdate("insert into employees values(1,'Sam')"); 

stmt.executeUpdate("insert into employees values(2,'Jane')"); 

These two statements are rolled-back through (the savepoint is ignored! the savepoint 

must be specified (e.g. 

conn.rollback(save1); ) in the rollback if you want to rollback to the savepoint): 

conn.rollback() ; 

The next two insert statements are executed fine. Their result will be in the output. 


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

Answer:

Explanation: 

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. 


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

Answer: A,C,F 

Explanation: 

Thejoin()methods waits for this thread to die. 


Q18. Given: 

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:

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) 

D:\Documents and Settings\useralbo\Desktop\1.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) { this.id = id; } 

public String getId() { return this.id; } 

public void setContactName(String cn) { this.contactName = cn;} public String 

getContactName() { return 

this.contactName; } public void setPhone(String phone) { this.phone = phone; } public 

String getPhone() 

{ return this.phone; } 

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; } 


Q19. Which three statements are correct about thread's sleep method? 

A. The sleep (long) method parameter defines a delay in milliseconds. 

B. The sloop (long) method parameter defines a delay in microseconds. 

C. A thread is guaranteed to continue execution after the exact amount of time defined in the sleep (long)parameter. 

D. A thread can continue execution before the amount of time defined in the sleep (long) parameter. 

E. A thread can continue execution after the amount of time defined in the sleep (long) parameter 

F. Only runtime exceptions are thrown by the sleep method. 

G. A thread loses all object monitors (lock flags) when calling the sleep method. 

Answer: A,C,E 

Explanation: 

sleep (long millis) not B Causes the currently executing thread to sleep (temporarily cease execution) for the specified number ofmilliseconds(A, not B) millis - the length of time to sleep in milliseconds. throws InterruptedException: - if another thread has interrupted the current thread. The interrupted status ofthe current thread is cleared when this exception is thrown. java.lang.Throwable java.lang.Exception java.lang.InterruptedException The thread does not lose ownership of any monitors. It means that if the thread has an object-monitor, all otherthreads that need that monitor are blocked. This method can be called regardless whether the thread has any monitor or not. 


Q20. Given: 

ConcurrentMap <String, String> PartList = new ConcurrentMap<>(); 

Which fragment puts a key/value pair in partList without the responsibility of overwriting an existing key? 

A. partList.out(key,"Blue Shirt"); 

B. partList.putIfAbsent(key,"Blue Shirt"); 

C. partList.putIfNotLocked (key,"Blue Shirt"); 

D. partList.putAtomic(key,"Blue Shirt") 

E. if (!partList.containsKey(key)) partList.put (key,"Blue Shirt"); 

Answer:

Explanation: 

putIfAbsent(K key, V value) 

If the specified key is not already associated with a value, associate it with the given value. 

Reference:java.util.concurrent,Interface ConcurrentMap<K,V>