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..
zizi21Asked:
Who is Participating?
 
basicinstinctConnect With a Mentor Commented:
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
 
sciuriwareConnect With a Mentor Commented:
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
sciuriwareCommented:
Sorry, in parallel ..........
0
 
gnoonConnect With a Mentor Commented:
>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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.