Tag Archives: interface

Given the code fragment: interface SampleClosable { public void close () throws java.io.IOException;

Given the code fragment:interface SampleClosable {public void close () throws java.io.IOException;}Which three implementations are valid? A. Option A B. Option B C. Option C D. Option D E. Option E Correct Answer: A,C,E A: Throwing the same exception is fine.C: Using a subclass of java.io.IOException (here java.io.FileNotFoundException) is fineE: Not using a throw clause is fine.

Which code fragment does a service use to load the service provider with a Print interface?

Which code fragment does a service use to load the service provider with a Print interface? A. private Print print = new com.service.Provider.PrintImpl(); B. private Print print = com.service.Provider.getInstance(); C. private java.util.ServiceLoader<Print> loader = new java.util.ServiceLoader<> (); D. private java.util.ServiceLoader<Print> loader = ServiceLoader.load (Print.class); Correct Answer: D