Java OCA OCP Practice Question 1704

Question

How restrictive is the default accessibility compared to public, protected, and private accessibility?

Select the one correct answer.

  • (a) Less restrictive than public.
  • (b) More restrictive than public, but less restrictive than protected.
  • (c) More restrictive than protected, but less restrictive than private.
  • (d) More restrictive than private.
  • (e) Less restrictive than protected from within a package, and more restrictive than protected from outside a package.


(c)

Note

The default accessibility for members is more restrictive than protected accessibility, but less restrictive than private.

Members with default accessibility are only accessible within the class itself and from classes in the same package.

Protected members are, in addition, accessible from subclasses anywhere.

Members with private accessibility are only accessible within the class itself.




PreviousNext

Related