Which access modifier allows a member to be accessed from within its own class only?

  • default (no modifier)
  • private
  • protected
  • public
In Java, the private access modifier restricts access to the member to within the same class only. It is used to encapsulate the implementation details and hide them from external classes. The other options allow varying degrees of access to the member from outside the class.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *