Virtual of 1Z0-804 vce materials and ebook for Oracle certification for consumer, Real Success Guaranteed with Updated 1Z0-804 pdf dumps vce Materials. 100% PASS Java SE 7 Programmer II Exam exam Today!

2016 Sep 1z0-804 and 1z0-805:

Q11. Given: 

String s = new String("3"); 

System.out.print(1 + 2 + s + 4 + 5); 

What is the result? 

A. 12345 

B. 3345 

C. 1239 

D. 339 

E. Compilation fails. 

Answer: B 

Explanation: 

1 and 2 are added. 

Then the string s is concatenated. 

Finally 3 and 4 are concatenated as strings. 


Q12. Given: 

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


Q13. Which code fragment correctly appends "Java 7" to the end of the file /tmp/msg.txt? 

A. FileWriter w = new FileWriter("/tmp/msg.txt"); 

append("Java 7"); 

close(); 

B. FileWriter w = new FileWriter("/tmp/msg.txt", true); 

append("Java 7"); 

close(); 

C. FileWriter w = new FileWriter("/tmp/msg.txt", FileWriter.MODE_APPEND); 

append("Java 7"); 

close(); 

D. FileWriter w = new FileWriter("/tmp/msg.txt", Writer.MODE_APPEND); 

append("Java 7"); 

close(); 

Answer: B 

Explanation: 

FileWriter(File file, boolean append) 

A: clears the file and append "Java7" 

Constructs a FileWriter object given a File object. 

If the second argument is true, then bytes will be written to the end of the file rather than 

the beginning.Parameters: 

file - a File object to write toappend - if true, then bytes will be written to the end of the file 

rather than the beginning 


Q14. 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: D 

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. 


Q15. Given: What is the result? 

A. 1 

B. 0 

C. 2 

D. Compilation fails 

E. An exception is thrown at runtime 

Answer: E 

Explanation: Section: (none) 

Explanation 

The code compiles fine. 

java.lang.NullPointerException 

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) 

Note:binarySearch 

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. 

Parameters: 

a - the array to be searched. 

key - the value to be searched for. 

Returns: 

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. 


certifyforall.com

Avant-garde 1z0-804 braindump:

Q16. Which statement declares a generic class? 

A. public class Example < T > { } 

B. public class <Example> { } 

C. public class Example <> { } 

D. public class Example (Generic) { } 

E. public class Example (G) { } 

F. public class Example { } 

Answer: A 

Explanation: 

Example: 

public class Pocket<T> 

private T value; 

public Pocket() {} 

public Pocket( T value ) { this.value = value; } 

public void set( T value ) { this.value = value; } 

public T get() { return value; } 

public boolean isEmpty() { return value != null; } 

public void empty() { value = null; } 


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

Explanation: 

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) 


Q18. Given: 

Which statement, inserted at line 8, enables the code to compile? 

A. new Task().new Counter().increment(); 

B. new Task().Counter().increment(); 

C. new Task.Counter().increment(); 

D. Task.Counter().increment(); 

E. Task.Counter.increment(); 

Answer: C 


Q19. Given: 

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: A,C 


Q20. Given: 

What is the result? 

A. Nice to see you,be fine 

B. Nice,see you,be fine 

C. Nice,see you, to, be fine 

D. Nice, see you, be fine 

E. Nice to see y, u, be fine 

Answer: A 

Explanation: 

The text ",to," is replaced by the ","