A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction ?

A. Declare the method with the keyword public.

B. Declare the method with the keyword private.

C. Do not declare the method with any accessibility modifiers.

D. Declare the method with the keyword public and private.

Found an error? Read our corrections policy and submit a sourced correction below. You can also share a useful explanation in your own words.

Discuss the answer or suggest a sourced correction
Thank you for contributing.
Your comment was submitted and will appear after editorial review.

Your email is used only for moderation and is never displayed. Spam, copied material and fabricated endorsements are rejected.