[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 139
  • Last Modified:

package previledges

hi,

I thought that if i were to remove private , public or protected like this

private String name to

String name

i was informed that the it is not private by default but it has package priviledge ? Is that true ? what is that ?

in C++, it is defaulted to private..
0
zizi21
Asked:
zizi21
3 Solutions
 
basicinstinctCommented:
Yes it's true, it gets package scope.  That means only classes in the same package can see it.  


A protected method is visible to inheriting classes, even not part of the same package. A package scope (default) method is not. That is the only difference between protected and package scope.
http://mindprod.com/jgloss/packagescope.html
0
 
sciuriwareCommented:
It means that all methods from classes in the same package can access it.

If you leave a package declaration at the top of a source out, then that source
is member of the package "blank".

Then JAVA sources of the package (e.g.) "Communication" can not access the
items that are not public.

;JOOP!
0
 
Ajay-SinghCommented:
> i was informed that the it is not private by default but it has package
priviledge ?
 
True
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
sciuriwareCommented:
Sorry, in parallel ..........
0
 
gnoonCommented:
>Is that true ?
yes

>what is that ?
Without modifier, it switch to package-private security. Only class itself (but not subclasses), and other classes in the same package can access the variable, which different from private modifier. http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
0
 
zizi21Author Commented:
thanks :-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now