Skip to content
Sharp

Project Structure · interview question

In a JPMS setup, what happens if a module exports a package but does not specify which other modules can access it?

Multiple choiceMediumchapter-10-curatedpremiumproject-structurejava-modules-jpms
Choose one answer
Answer and explanation

Correct answer

A. Only modules requiring it can access

Why

When a module exports a package without specifying which modules can access it, any module that requires the exporting module can access the package. This is the default behavior of the 'exports' directive.

Test yourself on Project Structure

A free test with instant, explained results. No account needed.

Start free test
All Project Structure questions →