Java OCA OCP Practice Question 1153

Question

Fill in the blanks:

The ____ access modifier allows access to everything the ___ access modifier does and more.

  • A. package-private, protected
  • B. protected, public
  • C. protected, package-private
  • D. private, package-private


C.

Note

The protected modifier allows access by subclasses and members within the same package, while the package-private modifier allows access only to members in the same package.

The protected access modifier allows access to everything the package-private access modifier, plus subclasses, making Option C the correct answer.

Options A, B, and D are incorrect because the first term is a more restrictive access modifier than the second term.




PreviousNext

Related