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. Declare the method with the keyword protected.
D. Do not declare the method with any accessibility modifiers.
E. Declare the method with the keyword public and private.
Answer: Option D
Join The Discussion
Comments ( 2 )
Related Questions on Declaration and Access Control
What is the default access modifier for class members in Java if no access modifier is specified?
A. public
B. protected
C. private
D. package-private
A. private
B. public
C. protected
D. package-private
What keyword is used to declare a constant in Java, which is implicitly final and static?
A. final
B. const
C. static
D. constant
A. protected
B. private
C. public
D. default
but even if we do not specify any acc.. modifier the default modifier of Class is Private so how option D is correct??...?...
52.Which of the following events will cause a thread to die?