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. What are two differences between Callable and Runnable? 

A. A Callable can return a value when executing, but a Runnable cannot. 

B. A Callable can be executed by a ExecutorService, but a Runnable cannot. 

C. A Callable can be passed to a Thread, but a Runnable cannot. 

D. A Callable can throw an Exception when executing, but a Runnable cannot. 

Answer: A,D 

Explanation: 

The Callable interface is similar to Runnable, in that both are designed for classes whose instances arepotentially executed by another thread. A Runnable, however, does not return a result and cannot throw achecked exception. 


Q32. Which is a factory method from the java.text.NumberFormat class? 

A. format (long number) 

B. getInstance() 

C. getMaxiraumFractionDigits () 

D. getAvailableLocales () 

E. isGroupingUsed() 

Answer: B 

Explanation: 

To obtain a NumberFormat for a specific locale, including the default locale, call one ofNumberFormat's factory methods, such as getInstance(). Reference:java.textClass DecimalFormat 


Q33. Given the integer implements comparable: 

What is the result? 

A. 4 1 

B. 1 2 

C. 32 

D. 21 

E. 2 3 

Answer: D 

Explanation: 

binarySearch 

public static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key) 

Searches the specified list for the specified object using the binary search algorithm. 

The list must be sorted into ascending order according to the natural ordering of its 

elements (as by the sort(List) method) prior to making this call. If it is not sorted, the results 

are undefined. 

Parameters: 

list - the list to be searched. 

key - the key to be searched for. 

Returns: 

the index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1). 


certifyforall.com

Rebirth java 1z0-804:

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

Answer: B 

Explanation: 

getName() is missing in John, hence Pupils getName() is invoked and the String in Pupils scope returned. 


Q35. Sam has designed an application. It segregates tasks that are critical and executed frequently from tasks thatare non critical and executed less frequently. He has prioritized these tasks based on their criticality andfrequency of execution. After close scrutiny, he finds that the tasks designed to be non critical are rarely gettingexecuted. 

From what kind of problem is the application suffering? 

A. race condition 

B. starvation 

C. deadlock 

D. livelock 

Answer: C 

Explanation: 

Starvation describes a situation where a thread is unable to gain regular access to sharedresources and is unable to make progress. This happens when shared resources are made unavailable forlong periods by "greedy" threads. For example, suppose an object provides a synchronized method that oftentakes a long time to return. If one thread invokes 

this method frequently, other threads that also need frequentsynchronized access to the same object will often be blocked. Reference: The Java Tutorial, Starvation and Livelock 


Q36. Which code fragment demonstrates the proper way to handle JDBC resources? 

A. try { 

ResultSet rs = stmt.executeQuery (query); 

statement stmt = con.createStatement(); 

while (rs.next()) (/* . . . */) 

} catch (SQLException e) {} 

B. try { 

Statement stmt = con.createStatement(); 

ResultSet rs = stmt.executeQuery (query); 

while (rs.next()) (/* . . . */) 

} catch (SQLException e) {} 

C. try { 

Statement stmt = con.createStatement(); 

ResultSet rs = stmt.executeQuery (query); 

while (rs.next()) (/* . . . */) 

} finally { 

rs.close(); 

stmt.close(); 

D. try { 

ResultSet rs = stmt.executeQuery (query); 

Statement stmt = con.createStatement(); 

while (rs.next()) (/* . . . */) 

} finally { 

rs.close(); 

stmt.close(); 

Answer: C 


1Z0-804  test questions

100% Guarantee oca ocp java se 7 programmer i & ii study guide (exams 1z0-803 and 1z0-804):

Q37. Given that myFile.txt contains: 

What is the result? 

A. 1: First 

2: Second 

3:

 Third 

B. 

1: First 

2: Second 

3:

 First 

C. 

1: First 

2: First 

3:

 First 

D. 

IOExcepton 

E. 

Compilation fails 

Answer: B 

Explanation: 

BufferedReader: mark() : Marks the present position in the stream. Subsequent calls to 

reset() will attempt toreposition the stream to this point. 

reset() : Resets the stream to the most recent mark. 

!! After last Line is read (readLine()), a trial to reset() throws IOException : Mark invalid 


Q38. A valid reason to declare a class as abstract is to: 

A. define methods within a parent class, which may not be overridden in a child class 

B. define common method signatures in a class, while forcing child classes to contain unique methodimplementations 

C. prevent instance variables from being accessed 

D. prevent a class from being extended 

E. define a class that prevents variable state from being stored when object Instances are serialized 

F. define a class with methods that cannot be concurrently called by multiple threads 

Answer: B 

Explanation: 

Note:An abstract method in Java is something like a pure virtual function in C++ (i.e., a virtualfunction that is declared = 0). In C++, a class that contains a pure virtual function is called an abstract classand cannot be instantiated. The same is true of Java classes that contain abstract methods. Any class with an abstract method is automatically abstract itself and must be declared as such. An abstract class cannot be instantiated. A subclass of an abstract class can be instantiated only if it overrides each of the abstract methods of itssuperclass and provides an implementation (i.e., a method body) for all of them. Such a class is often called aconcrete subclass, to emphasize the fact that it is not abstract. If a subclass of an abstract class does not implement all the abstract methods it inherits, that subclass is itselfabstract.static, private, and final methods cannot be abstract, since these types of methods cannot be overridden by asubclass. Similarly, a final class cannot contain any abstract methods. A class can be declared abstract even if it does not actually have any abstract methods. Declaring such a classabstract indicates that the implementation is somehow incomplete and is meant to serve as a superclass forone or more subclasses that will complete the implementation. Such a class cannot be instantiated. 


Q39. Given the code fragment: 

What is the result? 

A. M001, , 

B. M001, null, null 

C. M001, Sam, 

D. M001, Sam, null 

E. M001, Sam, ABC Inc (Frage unvolst.ndig!!!) 

F. Compilation fails 

G. A NullPointerException is thrown at runtime 

Answer: E 


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