Sample exam questions Sample questions by Oracle

1Z0-805 (Upgrade to Java SE 7) sample exam questions by Oracle

1z0-805 sample exam questions
Written by Mushfiq Mammadov

1. Given:

import java.io.*;
class MyResource1 implements AutoCloseable {
[nbsp count=4]public void close() throws IOException { // A1
[nbsp count=8]System.out.print("1 "); }
}
class MyResource2 implements Closeable {
[nbsp count=4]public void close()throws Exception { // A2
[nbsp count=8]System.out.print("2 "); }
}
public class Triangle {
[nbsp count=4]public static void main(String[] args) throws IOException {
[nbsp count=8]try ( MyResource1 r1 = new MyResource1(); // B1
[nbsp count=12]MyResource2 r2 = new MyResource2();) { // B2
[nbsp count=12]System.out.print("t ");
[nbsp count=8]}
[nbsp count=8]finally {
[nbsp count=12]System.out.print("f ");
[nbsp count=8]}
[nbsp count=4]}
}

What is the result?

A) t 2 1 f
B) t 1 2 f
C) Compilation fails due to errors on lines A1 and B1.
D) Compilation fails due to errors on lines A2 and B2.

 

2. Given:

1. import java.util.*;
2. public class Forever {
3. [nbsp count=4]public static void main(String[] args) {
4. [nbsp count=8]List x1 = new ArrayList();
5. [nbsp count=8]List x2 = new ArrayList<>();
6. [nbsp count=4]}
7. }

What happens when you compile the code?

A) Compilation succeeds.
B) Compilation fails due to multiple errors.
C) Compilation fails due to an error on line 4.
D) Compilation fails due to an error on line 5.

 

3. Which is most closely associated with the object – oriented design concept known as “has – a”?

A) DAO
B) factory
C) adapter
D) composition

 

4. Given

import java.util.*;
public class MyDates {
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]Calendar c = Calendar.getInstance(); // Line A
[nbsp count=4]}
}

Which two statements are true?

A) Line A is an example of using the DAO pattern.
B) Line A is an example of using the factory pattern.
C) Line A is an example of using the singleton pattern.
D) java.util.Calendar could be an abstract class.
E) Line A could be replaced with: Calendar c = new Calendar();

 

5. Which method can be used for establishing a connection to a JDBC 4.1 data source?
A) Class.getConnection()
B) DriverManager.forName()
C) DriverManager.getConnection()
D) DriverManager.registerDriver()

 

6. Given this code fragment:

// assume "myURL" is a valid URL
// assume that the initial value of a saving account is 0
try {
[nbsp count=4]Connection conn = DriverManager.getConnection(myURL);
[nbsp count=4]Statement s = conn.createStatement();
[nbsp count=4]// execute SQL to add 100 to the account
[nbsp count=4]// execute more SQL to add 300 to the account
[nbsp count=4]conn.commit();
} catch (Exception e) {
[nbsp count=4]e.printStackTrace();
}

What is the result?

A) An exception is thrown at runtime.
B) The account’s value is not changed.
C) The account’s value is incremented by 300.
D) The account’s value is incremented by 400.

 

7. Implementing which method will properly extend java.util.ListResourceBundle?
A) getContents()
B) addResources()
C) getBundle()
D) getKeys()

 

Answers:

1. D
2. A
3. D
4. B, D
5. C
6. D
7. A

 

Source: Oracle, Exam 805: Upgrade to Java SE 7

About the author

Mushfiq Mammadov

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.