Oracle Upgrade to Java SE 7 Programmer (1Z1-805日本語版) - 1Z1-805日本語 Exam Practice Test

Correct Answer: A
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).

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));
}
}
Correct Answer: E
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).

public static void getInfo() {
//insert code here
List fontCatalog = new ArrayList();
fontCatalog.add("Algerian");
fontCatalog.add("Cambria");
fontCatalog.add("Lucida Bright");
category.put("firstCategory",fontCatalog);
List entrySet = new ArrayList(category.entrySet());
Iterator it = entrySet.iterator();
while(it.hasNext()) {
System.out.println(it.next));
}
}
Correct Answer: B,C
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).

public static void main(String[] args) {
String source = "d:\\company\\info.txt";
String dest = "d:\\company\\emp\\info.txt";
//insert code fragment here Line **
} catch (IOException e) {
System.err.println ("Caught IOException: " + e.getmessage();
}
}
Correct Answer: B,C

public static void main(String[] args) { Path dir = Paths.get("d:\\company");
// insert code here. Line **
for (Path entry: stream) {
System.out.println(entry.getFileName());
}
} catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
Correct Answer: A,B
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).

public static void processFile () throws IOException { Try (FileReader fr = new FileReader ("logfilesrc.txt");
FileWriter fw = new FileWriter ("logfilesdst.txt") ) {
int i = fr.read();
}
}
Correct Answer: C
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).

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");
}
Correct Answer: A,D,E
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).

public class StringApp {
public static void main(String[] args) {
String[] str="Java SE,java EE,Java ME,java FX".split(",");
int count=0;
for(int i=0;i<str.length;i++) {
switch(str[i]) {
case "Java SE":
count++; continue;
case "Java EE":
count++; break;
case "Java ME":
count++; break;
case "Java FX":
count++; break;
}
}
System.out.println("Total match found="+count);
}
}
Correct Answer: B
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).

public static void main(String[] args) {
Path file = Paths.get("D:\\company\\report.txt");
try (SeekableByteChannel sbc = Files.newByteChannel(file,new OpenOption[]
sbc.position(5);
sbc.truncate(30);
} catch (IOException e) {
System.err.printin("Caught IOException: " + e.getMessage () } ;
}
}
Correct Answer: D
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
0
0
0
0