18. Acess modifier in Java?

There are four access modifier in Java

  •  Private : We can only access private modifier within a class, not outside the class
  • Default : We can access default modifier within the same package
  • Protected : We can access protected modifier within the same package and different package but it’s subclass
  • Public : We can access public modifier any where

Leave a Reply

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