Given: Which one is correct?
A. An IllegalThreadStateException is thrown at run time.
B. Three threads are created.
C. The compilation fails.
D. Four threads are created.
Given:
var fruits = List.of("apple", "orange", "banana", "lemon");
You want to examine the first element that contains the character n.
Which statement will accomplish this?
A. String result = fruits.stream().filter(f -> f.contains("n")).findAny();
B. fruits.stream().filter(f -> f.contains("n")).forEachOrdered(System.out::print);
C. Optional
D. Optional
Which code fragment prints 100 random numbers?
A. Option A
B. Option B
C. Option C
D. Option D
var numbers = List.of(0,1,2,3,4,5,6,7,8,9);
You want to calculate the average of numbers.
Which two codes will accomplish this? (Choose two.)
A. double avg = numbers.stream().parallel().averagingDouble(a -> a);
B. double avg = numbers.parallelStream().mapToInt (m -> m).average().getAsDouble();
C. double avg = numbers.stream().mapToInt (i -> i).average().parallel();
D. double avg = numbers.stream().average().getAsDouble();
E. double avg = numbers.stream().collect(Collectors.averagingDouble(n -> n));
Given: Which statement is equivalent to line 1?
A. double totalSalary = list.stream().map(e -> e.getSalary() * ratio).reduce(bo).ifPresent (p -> p.doubleValue());
B. double totalSalary = list.stream().mapToDouble(e -> e.getSalary() * ratio).sum;
C. double totalSalary = list.stream().map(Employee::getSalary * ratio).reduce(bo).orElse(0.0);
D. double totalSalary = list.stream().mapToDouble(e -> e.getSalary() * ratio).reduce(starts, bo);
Given:
and
What is the result?
A. A NullPointerException is thrown at run time.
B. The compilation fails.
C. 1 Null null
D. 1
E. A ClassCastException is thrown at run time.
Which statement about a functional interface is true?
A. It must be defined with the public access modifier.
B. It must be annotated with @FunctionalInterface.
C. It is declared with a single abstract method.
D. It is declared with a single default method.
E. It cannot have any private methods and static methods.
Given: What will secure this code from a potential Denial of Service condition?
A. After Line 4, add indexReader.close().
B. On Line 3, enclose processData(dataReader) with try with resources.
C. After Line 3, add dataReader.close().
D. On Line 1, use try with resources when opening each dataReader.
E. Before Line 1, check the size of dataFiles to make sure it does not exceed a threshold.
Which three annotation uses are valid? (Choose three.)
A. Function
B. var v = "Hello" + (@Interned) "World"
C. Function
D. Function
E. var myString = (@NonNull String) str;
F. var obj = new @Interned MyObject();
Which two statements independently compile? (Choose two.)
A. List super Short> list = new ArrayList
B. List super Number> list = new ArrayList
C. List extends Number> list = new ArrayList
D. List extends Number> list = new ArrayList
E. List super Float> list = new ArrayList