Cause all that matters here is passing the Oracle 1Z0-804 exam. Cause all that you need is a high score of 1Z0-804 Java SE 7 Programmer II Exam exam. The only one thing you need to do is downloading Examcollection 1Z0-804 exam study guides now. We will not let you down with our money-back guarantee.

Q1. Given this error message when running your application: 

Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name 

MessageBundle, locale 

And given that the MessageBundle.properties file has been created, exists on your disk, and is properlyformatted. 

What is the cause of the error message? 

A. The file is not in the environment path. 

B. The file is not in the classpath. 

C. The file is not in the javapath. 

D. You cannot use a file to store a ResourceBundle. 

Answer:

Explanation: 

ResourceBundle.getBundle is using a resource name; it isn't called ResourceBundle for 

nothing. 

You can create a custom ClassLoader and use that to load the data. 


Q2. To provide meaningful output for: 

System.out.print( new Item ()): 

A method with which signature should be added to the Item class? 

A. public String asString() 

B. public Object asString() 

C. public Item asString() 

D. public String toString() 

E. public object toString() 

F. public Item toString() 

Answer:

Explanation: 

Implementing toString method in java is done by overriding the Object's toString method. 

The javatoString() method is used when we need a string representation of an object. It is 

defined in Object class. Thismethod can be overridden to customize the String 

representation of the Object. 

Note: 

Below is an example shown of Overriding the default Object toString() method. The 

toString() method must bedescriptive and should generally cover all the contents of the 

object. 

class PointCoordinates { 

private int x, y; 

public PointCoordinates(int x, int y) { 

this.x = x; 

this.y = y; 

public int getX() { 

return x; 

public int getY() { 

return y; 

// Custom toString() Method. 

public String toString() { 

return "X=" + x + " " + "Y=" + y; 

}} 


Q3. Given: What is the result? 

A. Null 

B. class java.lang.ArraylndexOutOfBoundsException 

C. class java.lang.NullPointerException 

D. class java.lang.Exception 

E. Compilation fails. 

Answer:

Explanation: 

error: incompatible types e = new Exception(); required: RuntimeException found: Exception 


Q4. Given the code fragment: 

If the file userguide.txt does not exist, what is the result? 

A. An empty file iscreated and success is printed 

B. class java.io.FileNotFoundException 

C. class java.io.IOException 

D. class java.lang.Exception 

E. Compilation fails 

Answer:

Explanation: 

Compilation fails : Exception Exception is not compatible with throws clause in Base.process() IOExceptiondie Exception in der Derived Class Methode muss zur Base 

Class Methode passen. 


Q5. What will the following class print when run? 

A. javajava 

B. lavajava 

C. javajavac 

D. lavajavac 

E. None of these. 

Answer:


Q6. 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); 

Answer:

Explanation: 

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

method, as 

follows: 

Path file = ...; 

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

Note: 

setAttribute 

public static Path setAttribute(Path path, 

String attribute, 

Object value, 

LinkOption... options) 

throws IOException 

Sets the value of a file attribute. 

Reference:Interface DosFileAttribute 


Q7. Given the code fragment: What is the result? 

A. Null B D 

B. Null B null D 

C. B D 

D. D 

E. An exception is thrown at runtime 

Answer:


Q8. Given: 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:

Explanation: 

class Dog { 

protected String bark() 

public class Beagle extends Dog { 

private String bark() 

Cannot reduce the visibility of the inherited method from Dog 


Q9. Given: What is the result? 

A. p001 Widget p002 X-Large Widget 

B. p002 Large Widget p001 Widget 

C. p002 X-large Widget p001 Widget 

D. p001 Widget p002 Large Widget 

E. compilation fails 

Answer:

Explanation: Compiles fine. Output is: P001 Widget P002 X-Large Widget Line: partList.put("P002", "X-Large Widget"); >> overwrites >> line:partList.put("P002", "Large Widget"); put V put(K key, V value) Associates the specified value with the specified key in this map (optional operation). If the map previouslycontained a mapping for the key, the old value is replaced by the specified value. (Amap m is said to contain amapping for a key k if and only if m.containsKey(k) would return true.) 

Parameters: key - key with which the specified value is to be associated value - value to be associated with the specified key Returnsthe previous value associated with key, or null if there was no mapping for key. (A null return can alsoindicate that the map previously associated null with key, if the implementation supports null values.) 


Q10. Given the following code fragment: 

What is the result? 

A. Three 

B. One 

C. Compilation fails 

D. The program runs, but prints no outout 

Answer:

Explanation: 

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