Which code fragment does a service use to load the service provider with a Print interface?
A. private Print print = com.service.Provider.getInstance();
B. private java.util.ServiceLoader
C. private java.util.ServiceLoader
D. private Print print = new com.service.Provider.PrintImpl();
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.
Given:
Which is true?
A. System.out is the standard output stream. The stream is open only when System.out is called.
B. System.in cannot reassign the other stream.
C. System.out is an instance of java.io.OutputStream by default.
D. System.in is the standard input stream. The stream is already open.
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.
Given:
And the command: java Main Helloworld What is the result ?
A. Input: Echo:
B. Input: Helloworld Echo: Helloworld
C. Input: Then block until any input comes from System.in.
D. Input: Echo: Helloworld
E. A NullPointerException is thrown at run time.
Given:
public class X { }
and public final class Y extends X { }
What is the result of compiling these two classes?
A. The compilation fails because there is no zero args constructor defined in class X.
B. The compilation fails because either class X or class Y needs to implement the toString() method.
C. The compilation fails because a final class cannot extend another class.
D. The compilation succeeds.
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")};
Which three guidelines are used to protect confidential information? (Choose three.)
A. Limit access to objects holding confidential information.
B. Clearly identify and label confidential information.
C. Manage confidential and other information uniformly.
D. Transparently handle information to improve diagnostics.
E. Treat user input as normal information.
F. Validate input before storing confidential information.
G. Encapsulate confidential information.
Given the code fragment:
var pool = Executors.newFixedThreadPool(5);
Future outcome = pool.submit(() -> 1);
Which type of lambda expression is passed into submit()?
A. java.lang.Runnable
B. java.util.function.Predicate
C. java.util.function.Function
D. java.util.concurrent.Callable
Given:
LocalDate d1 = LocalDate.of(1997,2,7); DateTimeFormatter dtf = DateTimeFormatter.ofPattern( /*insert code here*/ ); System.out.println(dtf.format (d1)); Which pattern formats the date as Friday 7th of February 1997?
A. "eeee dd+"th of"+ MMM yyyy"
B. "eeee dd'th of' MMM yyyy"
C. "eeee d+"th of"+ MMMM yyyy"
D. "eeee d'th of' MMMM yyyy"