Certified Java 1Z0-804 pdf

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.


2024 Oracle Official New Released 1Z0-804 ♥♥
https://www.certleader.com/1Z0-804-dumps.html


Q1. Given the code fragment: 

What is the result? 

A. Java 7 

B. Java 6 

C. Java 7, Java 6 

D. Java 7 java 6 

E. Java 

Answer:

Explanation: 

regex: Java / one or more anything !!! / ends with a digit so it is the source string 

Q2. Given the Greetings.properties file, containing: 

What is the result? 

A. Compilation fails 

B. HELLO_MSG 

C. GOODGYE_NSG 

D. Hello, everyone! 

E. Goodbye everyone! 

Answer:

Explanation: 

The code will not compile. 

The problem is the following line: 

System.out.println(resource.getObject(1)); 

In particular getObject(1) throws the following error: 

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code -Erroneous sym type: 

<any>.loadResourceBundle 

Note:getObject(String key) !!! String keyGets an object for the given key from this resource 

bundle or one of its parents. 

Q3. Which three statements are correct about thread's sleep method? 

A. The sleep (long) method parameter defines a delay in milliseconds. 

B. The sloop (long) method parameter defines a delay in microseconds. 

C. A thread is guaranteed to continue execution after the exact amount of time defined in the sleep (long)parameter. 

D. A thread can continue execution before the amount of time defined in the sleep (long) parameter. 

E. A thread can continue execution after the amount of time defined in the sleep (long) parameter 

F. Only runtime exceptions are thrown by the sleep method. 

G. A thread loses all object monitors (lock flags) when calling the sleep method. 

Answer: A,C,E 

Explanation: 

sleep (long millis) not B Causes the currently executing thread to sleep (temporarily cease execution) for the specified number ofmilliseconds(A, not B) millis - the length of time to sleep in milliseconds. throws InterruptedException: - if another thread has interrupted the current thread. The interrupted status ofthe current thread is cleared when this exception is thrown. java.lang.Throwable java.lang.Exception java.lang.InterruptedException The thread does not lose ownership of any monitors. It means that if the thread has an object-monitor, all otherthreads that need that monitor are blocked. This method can be called regardless whether the thread has any monitor or not. 

Q4. Given: 

What is the result? 

A. peach orange apple 

B. peach orange 

C. apple orange 

D. The program does not compile. 

E. The program generates an exception at runtime. 

Answer:

Explanation: 

int compare(T obj1, T obj2) 0 if equal positive if obj1 greater negative if obj2 greater The compiler has a problem with the line: public boolean compare(String s1, String s2) { return s1.length() > s2.length(); error: <anonymous comparetest.CompareTest$1> is not abstract and does not override abstract method compare(String,String) in Comparator 

new Comparator<String>() { 

Error: compare(String,String) in <anonymous comparetest.CompareTest$1> cannot 

implement compare(T,T) 

in Comparator 

public boolean compare(String s1, String s2) { 

return type boolean is not compatible with int 

where T is a type-variable: 

T extends Object declared in interface Comparator 

Q5. Given a language code of fr and a country code of FR, which file name represents a resource bundle file namethat is not the default? 

A. MessageBundle_fr_FR.properties 

B. MessageBundle_fr_FR.profile 

C. MessageBundle_fr_FR.xinl 

D. MessageBundle__fr__FR.Java 

E. MessageBundle__fr__FR.Locale 

Answer:

Explanation: 

The default file is MessageBundle.properties. The non-default file name is 

MessageBundle_fr_FR.properties 

Note 0:.properties is a file extension for files mainly used in Java related technologies to 

store the configurableparameters of an application. They can also be used for storing 

strings for Internationalization and localization;these are known as Property Resource 

Bundles. Each parameter is stored as a pair of strings, one storing thename of the 

parameter (called the key), and the other storing the value.Note 1:You can obtain an 

instance of ResourceBundle by calling its static getBundle method.public static 

ResourceBundle getBundle(java.lang.String baseName) public static ResourceBundle 

getBundle(java.lang.String baseName, Locale locale) For example: 

ResourceBundle rb = ResourceBundle.getBundle("MyResources", Locale.US); This will 

load theResourceBundle object with the values in the corresponding properties file.1.If a 

suitable properties file is not found, the ResourceBundle object will use the default 

properties file, whichwill be the one whose name equals the base name and has the 

properties extension. In this case, the defaultfile would be MyResources.properties. 2.If this 

file is not found, a java.util.MissingResourceException will bethrown. 

Note2:java.util.ResourceBundle class enables you to choose and read the properties file 

specific to the user'slocale and look up the values. 

A ResourceBundle object has a base name. In order for a ResourceBundle object to pick 

up a properties file,the filename must be composed of the ResourceBundle base name, 

followed by an underscore, followed bythe language code, and optionally followed by 

another underscore and the country code. 

The format for the properties file name is as follows: 

basename_languageCode_countryCode 

For example, suppose the base name is MyResources and you define the following three 

locales: 

US-en DE-de CN-zh Then you would have these three properties files: MyResources_en_US.properties MyResources_de_DE.properties MyResources_zh_CN.properties 

Reference:Reading Properties Files using ResourceBundle 

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

Q7. Given the code fragment: 

Which three are true? 

A. On line 3, the current thread stops and waits until the t1 thread finishes. 

B. On line 3, the t1 thread stops and waits until the current thread finishes. 

C. On line 4, the t1 thread is dead. 

D. On line 4, the t1 thread is waiting to run. 

E. This code cannot throw a checked exception. 

F. This code may throw a checked exception. 

Answer: A,C,F 

Explanation: 

Thejoin()methods waits for this thread to die. 

Q8. Which code fragment is required to load a JDBC 3.0 driver? 

A. DriverManager.loadDriver ("org.xyzdata.jdbc.NetworkDriver"); 

B. Class.forName("org.xyzdata.jdbc-NetworkDriver"); 

C. Connection con = Connection.getDriver ("jdbc:xyzdata://localhost:3306/EmployeeDB"); 

D. Connection con = DriverManager.getConnection ("jdbc:xyzdata://localhost:3306/EmployeeDB"); 

Answer:

Explanation: 

In previous versions (prior to 4.0) of JDBC, to obtain a connection, you first had to initialize 

your JDBCdriver by calling the method Class.forName. This methods required an object of 

type java.sql.Driver. 

Note: 

DriverManager: This fully implemented class connects an application to a data source, 

which is specified by adatabase URL. When this class first attempts to establish a 

connection, it automatically loads any JDBC 4.0drivers found within the class path. Note 

that your application must manually load any JDBC drivers prior toversion 4.0. 

Q9. Which three are true? 

A. A setAutoCommit (False) method invocation starts a transaction context. 

B. An instance of Savepoint represents a point in the current transaction context. 

C. A rollback () method invocation rolls a transaction back to the last savepoint. 

D. A rollback () method invocation releases any database locks currently held by this connection object. 

E. After calling rollback (mysavepoint), you must close the savepoint object by calling mySavepoint.close() . 

Answer: A,B,C 

Explanation: 

A:The way to allow two or more statements to be grouped into a transaction is to disable the auto-commitmode. After the auto-commit mode is disabled, no SQL statements are committed until you call the methodcommit explicitly. All statements executed after the previous call to the method commit are included in thecurrent transaction and committed together as a unit. Note:When a connection is created, it is in auto-commit mode. This means that each individual SQL statementis treated as a transaction and is automatically committed right after it is executed. (To be more precise, thedefault is for a SQL statement to be committed when it is completed, not when it is executed. A statement iscompleted when all of its result sets and update counts have been retrieved. In almost all cases, however, astatement is completed, and therefore committed, right after it is executed.) 

B:The method Connection.setSavepoint, sets a Savepoint object within the current transaction. The Connection.rollback method is overloaded to take a Savepoint argument. When a transaction is rolled back toa savepoint all changes made after that savepoint are undone. 

C: calling the method rollback terminates a transaction and returns any values that were modified to theirprevious values. If you are trying to execute one or more statements in a transaction and get a SQLException, call the method rollback to end the transaction and start the transaction all over again. 

Q10. Given: 

What two changes, made independently, will enable the code to compile? 

A. Change the signature of Account to: public class Account. 

B. Change the signature of CheckingAccount to: public abstract CheckingAccount 

C. Implement private methods for deposit and withdraw in CheckingAccount. 

D. Implement public methods for deposit and withdraw in CheckingAccount. 

E. Change Signature of checkingAccount to: CheckingAccount implements Account. 

F. Make Account an interface. 

Answer: B,D 

Explanation: 

Compiler say: 

-

Der Typ CheckingAccount muss die übernommene abstrakte Methode Account.deposit(double) implementieren 

-

Der Typ CheckingAccount muss die übernommene abstrakte Methode Account.withdraw(double) implementieren ODER Typ CheckingAccount als abstract definieren