Which two are functional interfaces? (Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Given:
Examine these requirements:
Eliminate code duplication.
Keep constant the number of methods other classes may implement from this interface.
Which method can be added to meet these requirements?
A. Option A
B. Option B
C. Option C
D. Option D
Given:
What is required to make the Foo class thread safe?
A. No change is required.
B. Make the declaration of lock static.
C. Replace the lock constructor call with new ReentrantLock (true).
D. Move the declaration of lock inside the foo method.
Which code fragment compiles?
A. Option A
B. Option B
C. Option C
D. Option D
You are working on a functional bug in a tool used by your development organization. In your investigation, you find that the tool is executed with a security policy file containing this grant.
What action should you take?
A. Nothing, because it is an internal tool and not exposed to the public.
B. Remove the grant because it is excessive.
C. Nothing, because it is not related to the bug you are investigating.
D. File a security bug against the tool referencing the excessive permission granted.
E. Nothing, because listing just the required permissions would be an ongoing maintenance challenge.
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:
You want to use the myResource class in a try-with-resources statement. Which change will accomplish this?
A. Extend AutoCloseable and override the close method.
B. Implement AutoCloseable and override the autoClose method.
C. Extend AutoCloseable and override the autoClose method.
D. Implement AutoCloseable and override the close method.
Which code is correct?
A. Runnable r = "Message" -> System.out.println();
B. Runnable r = () -> System.out::print;
C. Runnable r = () -> {System.out.println("Message");};
D. Runnable r = -> System.out.println("Message");
E. Runnable r = {System.out.println("Message")};
Given:
When is the readObject method called?
A. before this object is deserialized
B. after this object is deserialized
C. before this object Is serialized
D. The method is never called.
E. after this object is serialized
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 the Person class with age and name along with getter and setter methods, and this code fragment:
What will be the result?
A. Aman Tom Peter
B. Tom Aman Peter
C. Aman Peter Tom
D. Tom Peter Aman
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:
What is the result?
A. Orange Juice
B. The compilation fails.
C. Orange Juice Apple Pie Lemmon Ice Raspberry Tart
D. The program prints nothing.
Which two statements independently compile? (Choose two.)
A. List list = new ArrayList
B. List list = new ArrayList
C. List list = new ArrayList
D. List list = new ArrayList
E. List list = new ArrayList
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