Given the following code fragment:
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));
}
}
Which two code fragments, when inserted independently at line **, enable the code to compile?
public class MyGrades {
private final List
}
}
System.out.println("The average is: " + sum/(i+1));
// release __________ lock Line ***
}
sum += myGrades.get(i);
for (i = 0; i < myGrades.size(); i++) {
int i = 0;
double sum = 0;
// acquire _______ lock Line **
public void averageGrades() {
}
*/
lock and modify
/*
public void addGrade(Integer grade) {
private final ReadWriteLock rwlock = new ReentrantReadWriteLock();
(); myGrades = new ArrayList
Which pair's statements should you insert at line ** and line *** (respectively) to acquire and release the most appropriate lock?
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?