1Z0-804 | What Validated 1Z0-804 practice test Is?


Q31. Given: 

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 

Answer:

Explanation: 

Class Snooker is public. Should be declared in a separate file. // Line 9 getCategory() >>> GetCategory() Line 13 

Q32. Given: 

And the command-line invocation: 

Java Tracker 12 11 

What is the result? 

A. General category 

B. class InvalidAgeException 

C. class java.lang.IllegalArgumentException 

D. class java.lang.RuntimeException 

Answer:

Explanation: 

The second argument 11 makes the program to throw an InvalidAgeException due to the 

line: 

if (age < 12) 

throw new InvalidAgeException (); 

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

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

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 

Q35. Given: 

Which fragment, inserted in the Books interface, enables the code to compile? 

A. public abstract String type; public abstract String getType(); 

B. public static String type; public abstract String getType(); 

C. public String type = "Fiction"; public static String getType(); 

D. public String type = "Fiction"; public abstract String getType(); 

Answer:

Q36. Given the code fragment: 

Assume that the SQL query matches one record. What is the result of compiling and executing this code? 

A. The code prints Error. 

B. The code prints the employee ID. 

C. Compilation fails due to an error at line 13. 

D. Compilation fails due to an error at line 14. 

Answer:

Explanation: 

The code compiles fine. 

A: prints Error: rs.next() fehlt !! Fehlermeldung: Before start of result set mit rs.next() Aufruf : The code would run fine. public int getInt(String columnName) throws SQLException Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Javaprogramming language 

Q37. Which two code blocks correctly initialize a Locale variable? 

A. Locale loc1 = "UK"; 

B. Locale loc2 = Locale.getInstance("ru"); 

C. Locale loc3 = Locale.getLocaleFactory("RU"); 

D. Locale loc4 = Locale.UK; 

E. Locale loc5 = new Locale("ru", "RU"); 

Answer: D,E 

Explanation: 

The Locale class provides a number of convenient constants that you can use to create 

Locale objects forcommonly used locales. 

For example, the following creates a Locale object for the United States: 

Locale.US 

E: Create a Locale object using the constructors in this class: 

Locale(String language) 

Locale(String language, String country) 

Locale(String language, String country, String variant) 

Reference: java.utilClass Locale 

Q38. Which two statements are true about RowSet subinterfaces? 

A. A JdbcRowSet object provides a JavaBean view of a result set. 

B. A CachedRowSet provides a connected view of the database. 

C. A FilteredRowSet object filter can be modified at any time. 

D. A WebRowSet returns JSON-formatted data. 

Answer: A,C 

Explanation: 

A: a JdbcRowSet object can be one of the Beans that a tool makes available for composing an application. Because a JdbcRowSet is a connected RowSet, that is, it continually maintains its connection to a databaseusing a JDBC technology-enabled driver, it also effectively makes the driver a JavaBeans component. 

C: The FilteredRowSet range criterion can be modified by applying a new Predicate object to the FilteredRowSet instance at any time. This is possible if no additional references to the FilteredRowSet objectare detected. A new filter has an immediate effect on criterion enforcement within the FilteredRowSet object,and all subsequent views and updates will be subject to similar enforcement. 

Reference: javax.sql Interface RowSet 

Q39. Give: What is the likely result? 

A. The program produces the correct result, with similar performance to the original. 

B. The program produces the correct result, with performance degraded to the equivalent of being singlethreaded. 

C. The program produces an incorrect result. 

D. The program goes into an infinite loop. 

E. An exception is thrown at runtime. 

F. The program produces the correct result, with better performance than the original. 

Answer:

Explanation: 

join() does not proceed until the task's result has been computed. Here we start to wait beforedoing the computing. The code will not finish. 

Q40. Given: 

import java.util.concurrent.atomic.AtomicInteger; 

public class AtomicCounter { 

private AtomicInteger c = new AtomicInteger(0); 

public void increment() { 

// insert code here 

Which line of code, inserted inside the increment () method, will increment the value of c? 

A. c.addAndGet(); 

B. c++; 

C. c = c+1; 

D. c.getAndIncrement (); 

Answer:

Explanation: getAndIncrement 

public final int getAndIncrement() 

Atomically increment by one the current value. 

Reference:java.util.concurrent.atomic