1Z0-819 · Question #134
Which two statements are true about Java modules? (Choose two.)
The correct answer is A. Modular jars loaded from --module-path are automatic modules. C. jdeps can be used to generate a digest of an unnamed module. A is correct because non-modular JARs (those without module-info.class) placed on --module-path become automatic modules - they get a name derived from the JAR filename and implicitly export all their packages. C is correct because jdeps (the Java Dependency Analysis tool) can…
Question
Options
- AModular jars loaded from --module-path are automatic modules.
- BAny named module can directly access all classes in an automatic module.
- Cjdeps can be used to generate a digest of an unnamed module.
- DModular jars loaded from classpath are automatic modules.
- EIf a package is defined in both the named module and the unnamed module, then the package in the unnamed module is ignored.
How the community answered
(56 responses)- A71% (40)
- B16% (9)
- D5% (3)
- E7% (4)
Explanation
A is correct because non-modular JARs (those without module-info.class) placed on --module-path become automatic modules - they get a name derived from the JAR filename and implicitly export all their packages. C is correct because jdeps (the Java Dependency Analysis tool) can analyze unnamed module code (classpath JARs) and generate module-info descriptors using flags like --generate-module-info, making it useful for migrating legacy code into the module system.
B is wrong because a named module must explicitly declare requires <automatic-module-name> in its module-info.java to access an automatic module's classes - access is not granted automatically to any named module. D is the classic trap: JARs on the classpath join the unnamed module, not automatic modules; automatic modules only arise from the module path. E is wrong because named modules are fully isolated from the unnamed module - a package split between the two doesn't result in one being "ignored"; named module code simply cannot reach unnamed module packages at all (only automatic modules and classpath code can read the unnamed module).
Memory tip: Think "Module-Path → Auto, ClassPath → Unnamed" - the two paths create two different module types, and they never swap. If you anchor on that, D is instantly eliminated and A falls into place.
Topics
Community Discussion
No community discussion yet for this question.