posted 3 years ago
Hi there,
Question 57 on page 258 asks what needs to be included in the module-info for it to be a service provider:
Question 56:
You have the following interface in a module named animal.insect.api.
Question 57:
And you have the following class in a module named animal.insect.impl and the service provider interface module from question 56 (from above). What needs to be included in the module-info for it to be a service provider? (Choose two.)
A. requires animal.insect.api.bugs;
B. requires animal.insect.lookup;
C. requires animal.printer;
D. provides animal.insect.impl.Worm;
E. provides animal.insect.api.bugs.Bug with animal.insect.impl.Worm;
F. provides animal.insect.impl.Worm with animal.insect.api.bugs.Bug;
And the answer on page 514 is:
A, E. This module is a service provider. It needs a requires directive for the service provider interface, which is option A. It also needs a provides directive which specifies both the interface and implementation. Option E has both in the correct order.
But A is not right because the directive is:
requires <module> not requires <package>
And question 58 also:
Suppose you have the following class in a module named animal.insect.lookup, the service provider interface from question 56 (from above), and the service provider from question 57. What needs to be included in the module-info file besides an exports directive for it to be a service locator? (Choose two.)
A. provides animal.insect.lookup;
B. provides animal.insect.lookup.InsectFinder;
C. requires animal.insect.api.bugs;
D. requires animal.insect.api.Bug;
E. uses animal.insect.api.bugs;
F. uses animal.insect.api.bugs.Bug;
And the answer on page 514 is:
C,F. This module is a service locator. It needs three directives: exports, requires, and uses. The requires directive specifies the module it depends on, which is option C. The uses directive specifies the service provider interface it references, which is option F.
Answer C is not right because like on question 58 requires directive needs a module not a package! And animal.insect.api.bugs is a package. In question 56 they name the interface module animal.insect.api not animal.insect.api.bugs
And the same problem is on question 59, with answer A,B, but A is not right because in A in the requires directive the package animal.insect.api.bugs is mentioned but it should be the module animal.insect.api!