Exam Code: 1Z0-804 (Practice Exam Latest Test Questions VCE PDF)
Exam Name: Java SE 7 Programmer II Exam
Certification Provider: Oracle
Free Today! Guaranteed Training- Pass 1Z0-804 Exam.
2016 May 1Z0-804 Study Guide Questions:
Q31. Given the code fragment:
Why is there no output when otherMethod is called?
A. An exception other than IOException is thrown.
B. Standard error is not mapped to the console.
C. There is a compilation error.
D. The exception is suppressed.
C: wenn printStackTrace() ohne Referenz auf das Exception object aufgerufen
A : java.io.FileNotFoundException: wenn e.printStackTrace();
The code compiles fine
FileInputStream fis = new FileInputStream(file))
will fail at runtime since file is an empty string.
public void printStackTrace()
Prints this throwable and its backtrace to the standard error stream.
Q32. Given the classes: What is the result?
A. John Harry
B. unknown Harry
C. john unknown
D. unknown unknown
E. Compilation fails.
F. An exception is thrown at runtime.
getName() is missing in John, hence Pupils getName() is invoked and the String in Pupils scope returned.
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");
putIfAbsent(K key, V value)
If the specified key is not already associated with a value, associate it with the given value.
Updated 1z0-804 exam preparation:
Q34. 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
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.
Q35. 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");
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...)
Path file = ...;
Files.setAttribute(file, "dos:hidden", true);
public static Path setAttribute(Path path,
Sets the value of a file attribute.
What is the result?
A. Cue sports, Cue sports
B. Compilation fails at line 9
C. Compilation fails at line 11
D. Compilation fails at line 12
E. Compilation fails at line 13
Class Snooker is public. Should be declared in a separate file. // Line 9 getCategory() >>> GetCategory() Line 13
Precise java exam 1z0-804:
Q37. Given: What is the result?
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 
elements  and  equals null
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
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.
Q38. Which four are true about enums?
A. An enum is typesafe.
B. An enum cannot have public methods or fields.
C. An enum can declare a private constructor.
D. All enums implicitly implement Comparable.
E. An enum can subclass another enum.
F. An enum can implement an interface.
Answer: A,C,D,F Explanation:
C: The constructor for an enum type must be package-private or private access. Reference: Java Tutorials,Enum Types
Q39. Given the fragment:
If thread a and thread b are running, but not completing, which two could be occurring?
D. loose coupling
A: A thread often acts in response to the action of another thread. If the other thread's action is also a responseto the action of another thread, then livelock may result. A thread often acts in response to the action ofanother thread. If the other thread's action is also a response to the action of another thread, then livelock mayresult.
B: Deadlock describes a situation where two or more threads are blocked forever, waiting for each other.
Q40. Given the code fragment:
Assume the method printNums is passed a valid array containing data. Why is this method not producingoutput on the console?
A. There is a compilation error.
B. There is a runtime exception.
C. The variable number is not initialized.
D. Standard error is mapped to another destination.
The code compiles fine.
The code runs fine.
The errorstream can be redirected.
System.out.println -> Sends the output to a standard output stream. Generally monitor.
System.err.println -> Sends the output to a standard error stream. Generally monitor. err is
the "standard" erroroutput stream. This stream is already open and ready to accept output
Typically this stream corresponds to display output or another output destination specified
by the hostenvironment or user. By convention, this output stream is used to display error
messages or other informationthat should come to the immediate attention of a user even if the principal output stream, the value of thevariable out, has been redirected to a file or other destination that is typically not continuously monitored.