Wednesday, 2 July 2014

Diffrent between protected and default packages?

      If member declared as protected then we can access that member with in the current package any where but out side package only in child classes.
      With in the current package we can access protected members either by parent reference or by child reference.
       But from out side package we can access protected members only by using child reference. if we are trying to use parent reference we will get the error.

       If member declared as the default, then we can access that member Only with in the current package
& we can't access from out side of the package, hence default access is also known as package level access.(Here Member means variables and methods)

No comments:

Post a Comment