Oracle Upgrade to Java SE 7 Programmer (1Z0-805) Free Practice Test
Question 1
Given this code fragment:
ResultSet rs = null;
try (Connection conn = DriverManager. getConnection (url) ) {
Statement stmt = conn.createStatement();
rs stmt.executeQuery(query);
//-.. other methods } } catch (SQLException se) {
System.out.println ("Error");
}
Which object is valid after the try block runs?
ResultSet rs = null;
try (Connection conn = DriverManager. getConnection (url) ) {
Statement stmt = conn.createStatement();
rs stmt.executeQuery(query);
//-.. other methods } } catch (SQLException se) {
System.out.println ("Error");
}
Which object is valid after the try block runs?
Correct Answer: B
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 2
Given the code fragment:
List<Person> pList = new CopyOnWriteArrayList<Person>();
Which statement is true?
List<Person> pList = new CopyOnWriteArrayList<Person>();
Which statement is true?
Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 3
Given the code format:
SimpleDateFormat sdf;
Which code statements will display the full text month name?
SimpleDateFormat sdf;
Which code statements will display the full text month name?
Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 4
The two methods of course rescue that aggregate the features located in multiple classes are __________.
Correct Answer: B,C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 5
Given the following code fragment:
public static void main(String[] args) {
Path tempFile = null;
try {
Path p = Paths.get("emp");
tempFile = Files.createTempFile(p, "report", ".tmp");
try (BufferedWriter writer = Files.newBufferedWriter(tempFile, Charset.forName("UTF8")))){
writer.write("Java SE 7");
}
System.out.println("Temporary file write done");
} catch(IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
What is the result?
public static void main(String[] args) {
Path tempFile = null;
try {
Path p = Paths.get("emp");
tempFile = Files.createTempFile(p, "report", ".tmp");
try (BufferedWriter writer = Files.newBufferedWriter(tempFile, Charset.forName("UTF8")))){
writer.write("Java SE 7");
}
System.out.println("Temporary file write done");
} catch(IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
What is the result?
Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 6
Given:
public class DAOManager {
public AccountDAO getAccountDAO() {
return new AccountJDBCDAO();
}
}
Which design pattern best describes the class?
public class DAOManager {
public AccountDAO getAccountDAO() {
return new AccountJDBCDAO();
}
}
Which design pattern best describes the class?
Correct Answer: A
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 7
Given the code fragment: public class Test {
public static void main (String [] args) {
Path path1 = Paths.get("D:\\sys\\asm\\.\\data\\..\\..\\mfg\\production.log");
System.out.println(path1.normalize());
System.out.println(path1.getNameCount());
}
}
What is the result?
public static void main (String [] args) {
Path path1 = Paths.get("D:\\sys\\asm\\.\\data\\..\\..\\mfg\\production.log");
System.out.println(path1.normalize());
System.out.println(path1.getNameCount());
}
}
What is the result?
Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 8
Given three resource bundles with these values set for menu1: ( The default resource bundle is
written in US English.)
English US resource Bundle
Menu1 = small
French resource Bundle
Menu1 = petit
Chinese Resource Bundle
Menu = 1
And given the code fragment:
Locale.setDefault (new Locale("es", "ES")); // Set default to Spanish and Spain
loc1 = Locale.getDefault();
ResourceBundle messages = ResourceBundle.getBundle ("messageBundle", loc1);
System.out.println (messages.getString("menu1"));
What is the result?
written in US English.)
English US resource Bundle
Menu1 = small
French resource Bundle
Menu1 = petit
Chinese Resource Bundle
Menu = 1
And given the code fragment:
Locale.setDefault (new Locale("es", "ES")); // Set default to Spanish and Spain
loc1 = Locale.getDefault();
ResourceBundle messages = ResourceBundle.getBundle ("messageBundle", loc1);
System.out.println (messages.getString("menu1"));
What is the result?
Correct Answer: A
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 9
Which two statements are true about RowSet subinterfaces?
Correct Answer: B,D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).