Given the code fragment:
and
module greeting {
}
Which statement is true?
Given the code fragment:
and
module greeting {
}
Which statement is true?
The correct statement is that public members in the com.name package are accessible only to the greeting module. This is because the export directive in the citizen module explicitly states that the com.name package is exported to the greeting module, meaning that only the greeting module can access the public members of com.name. Therefore, the correct option is B.
The correct answer is B. An exports module directive specifies one of the module’s packages whose public types (and their nested public and protected types) should be accessible to code in all other modules1. In this case, the citizen module exports the com.name package to the greeting module, making its public members accessible only to the greeting module.
The exports to directive in the citizen module doesn't exempt the target module from explicitly requiring the dependency module. Just specifying export package in the required module is not enough.
The correct statement is B. public members in the com.name package are accessible only to the greeting module
A is bad : citizen has only access to public members of pacakge
B is correct, to use exports to permit to access to public members from com.name wihtouht explicit requires in module-info .
Agree with Stavok. An exports…to directive enables you to specify in a comma-separated list precisely which module’s or modules’ code can access the exported package—this is known as a qualified export.
C does sound correct. B is probably not correct since the public members in com.name is also available to the citizen-module.
The correct answer should be C