1Z0-819 Modules System 5 — Questions and Answers
Question 1: What is the module name for the foundational Java SE module that all other modules implicitly depend on?
- java.core
- java.lang
- java.se
- java.base (Correct answer)
Correct answer: java.base
java.base is the foundational platform module containing java.lang, java.util, java.io, etc., and every module implicitly requires it.
Question 2: What command lists all observable modules in the current JDK installation?
- java --describe-module java.se
- jmod list
- java --list-modules (Correct answer)
- jlink --list-modules
Correct answer: java --list-modules
'java --list-modules' outputs all platform and observable modules available to the current JDK.
Question 3: A module-info.java declares 'opens com.example.data to com.google.gson;'. What capability does this grant?
- Only public method calls on types in com.example.data by com.google.gson
- com.google.gson can load classes from com.example.data with a custom ClassLoader
- com.google.gson can re-export com.example.data to other modules
- com.google.gson can reflectively access all members including private ones in com.example.data (Correct answer)
Correct answer: com.google.gson can reflectively access all members including private ones in com.example.data
A qualified 'opens' directive allows the target module to use reflection on all members, including private ones, in the opened package.
Question 4: What is the key difference between placing a JAR on --class-path versus --module-path?
- On --class-path the JAR exports all packages; on --module-path it exports none by default
- On --module-path the JAR is compiled; on --class-path it runs interpreted
- There is no difference; both paths are merged by the JVM at startup
- On --class-path it joins the unnamed module; on --module-path it becomes an automatic or named module (Correct answer)
Correct answer: On --class-path it joins the unnamed module; on --module-path it becomes an automatic or named module
Classpath JARs are aggregated into the unnamed module, while module-path JARs become named or automatic modules with encapsulation enforced.
Question 5: Which @Deprecated attribute, added in Java 9 alongside the module system, marks an API slated for removal?
- forRemoval=true (Correct answer)
- since="9", removal=true
- obsolete=true
- status=REMOVAL
Correct answer: forRemoval=true
The 'forRemoval=true' attribute on @Deprecated was added in Java 9 to signal that an API is scheduled for removal in a future release.
Question 6: What does the '--patch-module' option do when launching the JVM?
- Merges additional classes or resources into an existing named module at runtime (Correct answer)
- Replaces the module-info.class of a module with a custom descriptor
- Applies security patches to platform modules without recompiling
- Forces a module to re-read its module-info.class from disk
Correct answer: Merges additional classes or resources into an existing named module at runtime
'--patch-module module=path' injects additional classes into a named module, useful for testing and patching platform classes.
Question 7: Which module aggregates all standard Java SE API modules so you can depend on the full Java SE platform at once?
- java.base
- java.platform
- java.se (Correct answer)
- java.all
Correct answer: java.se
'java.se' is an aggregator module that requires all standard Java SE modules (java.desktop, java.sql, java.xml, etc.) transitively.
What is the module name for the foundational Java SE module that all other modules implicitly depend on?