Java Certification Path - Class Access - Default Access

A class with default access has no modifier preceding it in the declaration. The default access is a package-level access, because a class with default access can be seen only by classes within the same package. If a class has default access, a class in another package won’t be able to create a instance of that class, or even declare a variable or return type. The compiler will complain. For example:

package humanity;
class Person {}

package family;
import humanity.Person;
class Child extends Person {}

Try to compile this 2 sources. As you can see, they are in different packages, and the compilation will fail.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Furl
  • Ma.gnolia
  • Reddit
  • Slashdot
  • Technorati
  • YahooMyWeb
  • BlinkList
  • Netscape
  • NewsVine
  • StumbleUpon
  • TailRank
  • blinkbits
  • blogmarks
  • BlogMemes
  • co.mments
  • DotNetKicks
  • MisterWong
  • Smarking

Leave a Reply