Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

protected class ???

 
Prashanth Lingala
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why we cannot have a class as protected???
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nested classes can be protected.

If you look at the rules for accessing a protected entity from outside the same package, you'll see that they just wouldn't apply to a top level class. So the access choices for a top level class are public and default (package).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic