package previledges

Posted on 2007-10-19
Last Modified: 2010-03-30

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..
Question by:zizi21
    LVL 23

    Accepted Solution

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

    Assisted Solution

    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.

    LVL 23

    Expert Comment

    > i was informed that the it is not private by default but it has package
    priviledge ?
    LVL 24

    Expert Comment

    Sorry, in parallel ..........
    LVL 16

    Assisted Solution

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

    Author Comment

    thanks :-)

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Suggested Solutions

    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now