This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

protected and package/default access

 
FELIX ALE
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the major difference between protected and package/default access specifiers, someone should help me please.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
protected is less restrictive than the default and allows visibility to subclasses outside the package of the superclass. Default only allows access to subclasses within the same package as the superclass.
 
Niki Nono
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Protected works between packages and default works only in the same package.
this is the simplest explanation I can think of.
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I studied Java for the exam, I used a book which called the default accessor "package private". this name really tells a lot... ;-)

greets,
jan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic