Topic: 1z0-819 topic 1 question 127

Given the code fragment:



and

module greeting {
}

Which statement is true?

A.
All members of com.name are accessible only to the citizen and greeting modules.
B.
public members in the com.name package are accessible only to the greeting module.
C.
Inserting "requires citizen" at greeting's module-info.java, enables com.name members accessible to the greeting module.
D.
All members in the com.name package are accessible only to the greeting module.
E.
public members in the com.name package are accessible to all modules.

Re: 1z0-819 topic 1 question 127

The correct statement is B. public members in the com.name package are accessible only to the greeting module

Re: 1z0-819 topic 1 question 127

A is bad : citizen has only access to public members of pacakge

Re: 1z0-819 topic 1 question 127

B is correct, to use exports to permit to access to public members from com.name wihtouht explicit requires in module-info .

Re: 1z0-819 topic 1 question 127

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.

Re: 1z0-819 topic 1 question 127

C does sound correct.
B is probably not correct since the public members in com.name is also available to the citizen-module.

Re: 1z0-819 topic 1 question 127

The correct answer should be C

Re: 1z0-819 topic 1 question 127

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.