1Z0-819 · Question #180
Which two statements are correct about modules in Java? (Choose two.)
The correct answer is A. Java base exports all of the Java platforms core packages. C. A module can be packaged in module-info.java file. A is correct because java.base is the foundational Java module that is implicitly required by all modules and exports all core packages (like java.lang, java.util, java.io) without needing explicit requires declarations. C is correct because module-info.java is precisely where…
Question
Options
- AJava base exports all of the Java platforms core packages.
- Bmodule-info.java can be placed in any folder inside module-path.
- CA module can be packaged in module-info.java file.
- Dmodule-info.java cannot be empty.
- EBy default, modules can access each other as long as they run in the same folder.
How the community answered
(43 responses)- A81% (35)
- B5% (2)
- D2% (1)
- E12% (5)
Explanation
A is correct because java.base is the foundational Java module that is implicitly required by all modules and exports all core packages (like java.lang, java.util, java.io) without needing explicit requires declarations.
C is correct because module-info.java is precisely where a module is declared - it holds the module's name, its requires dependencies, and its exports directives, making it the definition file that "packages" a module's metadata.
B is wrong because module-info.java must reside at the root of the module's source directory, not in an arbitrary subfolder - placing it elsewhere causes a compilation error.
D is wrong because module-info.java can be empty in the sense that its body can contain no requires or exports statements - a bare module com.example {} is perfectly valid and compiles fine.
E is wrong because the entire point of the Java Platform Module System (JPMS) is strong encapsulation regardless of location - modules must explicitly exports packages and requires other modules; same-folder placement grants no special access.
Memory tip: Think of java.base as the foundation slab of a building - everything rests on it automatically. And remember module-info.java as the module's passport - it declares who the module is and what it shares. The JPMS slogan is "explicit beats implicit," so any answer suggesting automatic access is always wrong.
Topics
Community Discussion
No community discussion yet for this question.