Question discussion

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…

295840Medium 1 reply 4,201 views
31
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?
  • ADeclare the method with the keyword public.
  • BDeclare the method with the keyword private.
  • CDeclare the method with the keyword protected.
  • DDo not declare the method with any accessibility modifiers.
  • EDeclare the method with the keyword public and private.
Correct answer: D

Discussion 1

0
CCommunity
Do not declare the method with any accessibility modifiers.