Given:
class Sum extends RecursiveAction { //line n1
static final int THRESHOLD_SIZE = 3;
int stIndex, lstIndex;
int [ ] data;
public Sum (int [ ]data, int start, int end) {
this.data = data;
this stIndex = start;
this. lstIndex = end;
}
protected void compute ( ) {
int sum = 0;
if (lstIndex ?stIndex<;= THRESHOLD_SIZE) {
for (int i = stIndex; i < lstIndex; i++) {
sum += data [i];
}
System.out.println(sum);
} else {
new Sum (data, stIndex + THRESHOLD_SIZE, lstIndex).fork( );
new Sum (data, stIndex,
Math.min (lstIndex, stIndex + THRESHOLD_SIZE)
).compute ();
}
}
}
and the code fragment:
ForkJoinPool fjPool = new ForkJoinPool ( );
int data [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
fjPool.invoke (new Sum (data, 0, data.length));
and given that the sum of all integers from 1 to 10 is 55.
Which statement is true?
A. The program prints several values that total 55.
B. The program prints 55.
C. A compilation error occurs at line n1.
D. The program prints several values whose sum exceeds 55.
The data.doc, data.txt and data.xml files are accessible and contain text.
Given the code fragment:
Stream
Paths. get("data.txt"),
Paths. get("data.xml"));
paths.filter(s-> s.toString().endWith("txt")).forEach(
s -> {
try {
Files.readAllLines(s)
.stream()
.forEach(System.out::println); //line n1
} catch (IOException e) {
System.out.println("Exception");
}
}
);
What is the result?
A. The program prints the content of data.txt file.
B. The program prints: Exception <
C. A compilation error occurs at line n1.
D. The program prints the content of the three files.
Which two code blocks correctly initialize a Locale variable? (Choose two.)
A. Locale loc1 = "UK";
B. Locale loc2 = Locale.getInstance("ru");
C. Locale loc3 = Locale.getLocaleFactory("RU");
D. Locale loc4 = Locale.UK;
E. Locale loc5 = new Locale ("ru", "RU");
Given the code fragment:
public class FileThread implements Runnable { String fName;
public FileThread(String fName) { this.fName = fName; }
public void run () System.out.println(fName);}
public static void main (String[] args) throws IOException, InterruptedException {
ExecutorService executor = Executors.newCachedThreadPool();
Stream
listOfFiles.forEach(line -> {
executor.execute(new FileThread(line.getFileName().toString())); //
line n1
});
executor.shutdown();
executor.awaitTermination(5, TimeUnit.DAYS); //
line n2
}
}
The Java Projects directory exists and contains a list of files.
What is the result?
A. The program throws a runtime exception at line n2.
B. The program prints files names concurrently.
C. The program prints files names sequentially.
D. A compilation error occurs at line n1.
Given the code fragment:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of("UTC-7")); ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of("UTC-5")); long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1 System.out.println("Travel time is" + hrs + "hours");
What is the result?
A. Travel time is 4 hours
B. Travel time is 6 hours
C. Travel time is 8 hours
D. An exception is thrown at line n1.
Given: and the code fragment:


Which modification enables the code fragment to print Speaker?
A. Implement Predicate in the Product.ProductFilter class and replace line n2 with .filter (p -> p.ProductFilter.test (p))
B. Replace line n1 with: public static boolean isAvailable (Product p) {
C. Replace line n2 with: .filter (p -> p.ProductFilter: :isAvailable (p))
D. Replace line n2 with: .filter (p -> Product: :ProductFilter: :isAvailable ())
Given the code fragment: What is the result?

A. A compilation error occurs at line n1.
B. courseJava
C. Javacourse
D. A compilation error occurs at line n2.
Given the code fragment:

What is the result?
A. text1text2
B. text1text2text2text3
C. text1
D. [text1, text2]
Given the code fragments: and


What is the result?
A. Video played.Game played.
B. A compilation error occurs.
C. class java.lang.Exception
D. class java.io.IOException
Given the code fragment:
Map
books.put (1007, "A");
books.put (1002, "C");
books.put (1003, "B");
books.put (1003, "B");
System.out.println (books);
What is the result?
A. {1007=A, 1003=B, 1002=C}
B. {1007=A, 1003=B, 1003=B, 1002=C}
C. {1007=A, 1002=C, 1003=B, 1003=B}
D. {1002=C, 1003=B, 1007=A}