Oracle Certified Professional Java Se 11 Developer · Free Practice Question Medium

Question 7

Question ID: UKOCP48535


You as a developer, have task to modularize an application, which contains 3 jars: x.jar, y.jar and z.jar.


x.jar depends on y.jar and y.jar depends on z.jar. z.jar is a third-party library. You have decided to follow top-down approach for modularizing the application.


You have completed following tasks:

1. Converted x.jar to named module

2. Converted y.jar to named module


Which of the following is the best approach to follow, such that application executes successfully, without any future maintenance issues?

  • A Convert z.jar to named module
  • B Convert z.jar to automatic module
  • C Use z.jar as unnamed module
Reveal correct answer

Correct answer: B

Explanation

UKOCP48535:

Let's check all the options:

Convert z.jar to named module

✗  z.jar is a third-party library and you have no control over their releases. Every time they release a non-modular jars, you may have to convert it to named module, hence this approach will have maintenance issues.


Convert z.jar to automatic module

✓  If you don't specify Automatic-Module-Name in META-INF\MANIFEST.MF file, then by default name of the module will be 'z'. module descriptor of y.jar will have to add require z; directive once.


Use z.jar as unnamed module

✗  Please note that y.jar is a named module and a named module cannot access unnamed modules

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need