getcertified4sure.com

1Z0-804 Exam

The Secret of 1Z0-804 rapidshare




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.

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


Q12. Given the code fragment: 

What is the result when the result.txt file already exists in c:\student? 

A. The program replaces the file contents and the file's attributes and prints Equal. 

B. The program replaces the file contents as well as the file attributes and prints Not equal. 

C. An UnsupportedOperationException is thrown at runtime. 

D. The program replaces only the file attributes and prints Not equal. 

Answer:

Explanation: 

Assuming there is a file D:\\faculty\\report.txt then this file will be copied and will be replacing C:\\student\\report.txt. 


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


Q14. Given: 

Which two statements, inserted independently at line ***, enable the program to produce the following output: 

We have 002 Blue pants that cost $24.99. 

A. System.out.printf("We have %03d %s pants that cost $%3.2f.\n",quantity, color, price); 

B. System.out.printf("We have$03d$s pants that cost $$3.2f.\n",quantity, color, price); 

C. String out = String.format ("We have %03d %s pants that cost $%3.2f.\n",quantity, 

color,price); 

System.out.println(out); 

D. String out = System.out.format("We have %03d %s pants that cost $%3.2f.",quantity, 

color, price); 

System.out.println(out); 

E. System.out.format("We have %s%spants that cost $%s.\n",quantity, color, price); 

Answer: A,C 


Q15. Given: What is the result? 

A. 1 1 1 1 1 

B. 1 2 3 4 5 

C. 0 1 2 3 4 

D. 0 1 4 3 4 

Answer:

Explanation: 

first for-loop set 0 0 0 0 0 second for-loop increments each to 1 1 1 1 1 if condition is not given 


Q16. Which two codes correctly represent a standard language locale code? 

A. ES 

B. FR 

C. U8 

D. Es 

E. fr 

F. u8 

Answer: A,B 

Explanation: 

Language codes are defined by ISO 639, an international standard that assigns two- and three-letter codes tomost languages of the world. Locale uses the two-letter codes to identify the target language. 


Q17. Given the code fragment: 

What is the result? 

A. getName (0): C:\ 

subpath (0, 2): C:\education\report.txt 

B. getName(0): C:\ 

subpth(0, 2): C:\education 

C. getName(0): education 

subpath (0, 2): education\institute 

D. getName(0): education 

subpath(0, 2): education\institute\student 

E. getName(0): report.txt 

subpath(0, 2): insritute\student 

Answer:

Explanation: 

Example: 

Path path = Paths.get("C:\\home\\joe\\foo"); 

getName(0) 

-> home 

subpath(0,2) 

Reference: The Java Tutorial, Path Operations 


Q18. What will the following class print when run? 

A. javajava 

B. lavajava 

C. javajavac 

D. lavajavac 

E. None of these. 

Answer:


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


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