• Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between protected or default  RSS feed

 
sahil kumar garg sangrur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello sir,
i am new in java
please let me know one thing

is there any difference between protected or default when we are talking about one package?

thanks
with regards,
sahil garg
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tutorial page Controlling Access to Members of a Class contains a table that shows what the different access modifiers mean.

The difference between protected and no modifier (default access) is that protected members are visible in subclasses, no matter if these subclasses are in another package or not, while with no modifier, members are only visible in classes in the same package, and not in a subclass, if the subclass is in a different package.

So, what do you think that means if you have only one package?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!