Java SE 11 Developer (1Z0-819) — Question 98

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

Answer options

Correct answer: A

Explanation

Option A is correct because it correctly uses ServiceLoader to load the service provider for the Print interface. Options B and D instantiate the Print implementation directly, bypassing the service loading mechanism, while option C incorrectly initializes a new ServiceLoader without specifying the Print interface.