Oracle 1Z1-805 Actual Free Exam Questions & Community Discussion

  • Exam Code/Number: 1Z1-805
  • Exam Name/Title: Upgrade to Java SE 7 Programmer
  • Certification Provider: Oracle
  • Corresponding Certification: OCP
  • Exam Questions: 90
  • Updated On: Aug 11, 2026
Consider the following five methods:

Which method should you use to connect to a java Db database with JDBC 4.0, but not with
previous versions of JDBC?
Correct Answer: B Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
Given:
public class MyGrades {
private final List<Integer> myGrades = new ArrayList<Integer>();
private final ReadWriteLock rwlock = new ReentrantReadWriteLock();
public void addGrade(Integer grade) {
/*
lock and modify
*/
}
public void averageGrades() {
// acquire _______ lock Line **
double sum = 0;
int i = 0;
for (i = 0; i < myGrades.size(); i++) {
sum += myGrades.get(i);
}
// release __________ lock Line ***
System.out.println("The average is: " + sum/(i+1));
}
}
Which pair's statements should you insert at line ** and line *** (respectively) to acquire and release the most appropriate lock?
Correct Answer: C Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
Given the code fragment:
11.
public static getFileSize () throws IOException {
12.
path file = paths.get ("ex.txt");
13.
//insert code here
14.
System.out.println ("size: " + attr.size());
15.
}
public static getFileSize () throws IOException {
Path file = Paths.get ("ex.txt");
//insert code here Line **
System.out.println ("size: " + attr.size());
}
Which two fragments, when inserted independently at line **, enable printing of the file size?
Correct Answer: A,D Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
Given the code fragment:
public static void processFile () throws IOException { Try (FileReader fr = new FileReader ("logfilesrc.txt");
FileWriter fw = new FileWriter ("logfilesdst.txt") ) {
int i = fr.read();
}
}
Which statement is true?
Correct Answer: B Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
Which two methods are defined in the FileStore class print disk space information?
Correct Answer: B,C Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
Given this code fragment:
try {
String query = "SELECT * FROM Item";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int rowCount = rsmd.getRowCount();
System.out.println ("Processing: " + rowCount + " rows.");
while (rs.next()) {
// Process each row
}
} catch (SQLException se) {
System.out.println("Error");
}
Assume that the SQL query returns records. What is the result?
Correct Answer: A Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
Given:
import java.io.*;
public class SampleClass {
public static void main(String[] args) throws IOException {
try {
String dirName = args[0];
File dir = new File(dirName);
File.createTempFile("temp", "log", dir);
} catch (NullPointerException | IOException e) {
e = new IOException("Error while creating temp file");
throw e;
}
}
}
What is the result?
Correct Answer: A Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
Given the code fragment:
private static void copyContents (File source, File target) {
try {inputStream fis = new FileInputStream(source);
outputStream fos = new FileOutputStream (target);
byte [] buf = new byte [8192]; int i;
while ((i = fis.read(buf)) != -1) {
fos.write (buf, 0, i);
}
//insert code fragment here. Line **
System.out.println ("Successfully copied");
}
Which code fragments, when inserted independently at line **, enable the code to compile?
Correct Answer: C,D,E Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
What are two benefits of a Factory design pattern?
Correct Answer: A,B Vote an answer
Explanation: Only visible for EduDump members. You can sign-up / login (it's free).
0
0
0
10