Online Access Free 1Z1-805 Practice Test
| Exam Code: | 1Z1-805 |
| Exam Name: | Upgrade to Java SE 7 Programmer |
| Certification Provider: | Oracle |
| Free Question Number: | 90 |
| Posted: | Oct 30, 2025 |
Given the code fragment:
/* method declaration */ { try {
String className = "java.lang.String";
String fieldname = "somefield";
Class c = Class.forName(className);
Field f = c.getField(fieldname);
} catch(Exception e) {
e.printStackTrace();
throw e;
}
}
Which two method declarations are valid options to replace /* method declaration */?
Which three must be used when using the Java.util.concurrent package to execute a task that returns a result without blocking?
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?
Given the code fragment: SimpleDateFormat sdf = new SimpleDateFormat("zzzz", Locale.US);
System.out.println ("Result: " + sdf.format(today) ) ;
What type of result is printed?