package previledges


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..
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.
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.

> i was informed that the it is not private by default but it has package
priviledge ?
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.

Sorry, in parallel ..........
gnoonConnect With a Mentor Commented:
>Is that true ?

>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.
zizi21Author Commented:
thanks :-)
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.