Given:
Which two interfaces can be used in lambda expressions? (Choose two.)
A. MyInterface1
B. MyInterface3
C. MyInterface5
D. MyInterface2
E. MyInterface4
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:
What is the output?
A. null
B. A NoSuchElementException is thrown at run time.
C. Duke
D. A NullPointerException is thrown at run time.
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:
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:
Which two are correct? (Choose two.)
A. The output will be exactly 2 1 3 4 5.
B. The program prints 1 4 2 3, but the order is unpredictable.
C. Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5, but the order is unpredictable.
D. Replacing forEach() with forEachOrdered(), the program prints 1 2 3 4 5.
E. Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5.
Given:
Which is true about line 1?
A. If the value is not present, a NoSuchElementException is thrown at run time.
B. It always executes the System.out::print statement.
C. If the value is not present, a NullPointerException is thrown at run time.
D. If the value is not present, nothing is done.
Which two statements set the default locale used for formatting numbers, currency, and percentages? (Choose two.)
A. Locale.setDefault(Locale.Category.FORMAT, "zh-CN");
B. Locale.setDefault(Locale.Category.FORMAT, Locale.CANADA_FRENCH);
C. Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
D. Locale.setDefault("en_CA");
E. Locale.setDefault("es", Locale.US);
Given: Which annotation should be used to remove warnings from compilation?
A. @SuppressWarnings on the main and print methods
B. @SuppressWarnings("unchecked") on main and @SafeVarargs on the print method
C. @SuppressWarnings("rawtypes") on main and @SafeVarargs on the print method
D. @SuppressWarnings("all") on the main and print methods