Protected and public access modifier - exact difference

Hi everybody,
Please help me to give an exact difference between protected access modifier and public
Protected: Classes with in the same package as well as subclasses can access.
Public : Classes outside the current class can access while declaring public.
My doubt is that what is the practical difference between public and protected.
I searched the net , but the information was not satisfactory to solve my confusion.
Thanks & regards
Parvathy

Obviously doubt = lacks the ability to think for
oneself.When one person raises a doubt, that does n't mean that he lacks the ability to think . He/She might have thought about it and if he didnt get a proper clarification then it will be posted in the forum.
In such cases please dont discourage others who are ready to answer the subject.Without knowing the actual intention , i request you please dont reply like this

Similar Messages

  • Use of public access modifier in main method

    I want to know what is the significance of public access modifier with main (String args[]) method. Like generally we write
    public static void main(String args[])
    But if we write
    private static void main(String args[])
    OR
    protected static void main(String args[])
    then also its working properly.............
    then what is the use of public keyword..........................
    Regards
    Ajay Pratap Singh

    then what is the use of public keyword..........................Convention, I believe. And I think newer versions of the JVM require it.
    P.S. Relax a bit on the punctuation overuse. Many folks around here find that a bit irritating, and you probably don't intend to send that kind of a message. Cheers!

  • Content Protection and AppWorld Access

    hello good day to all.
    my problem with my curve 9360 is that i cannot connect to Blackberry World it says "We cannot connect you to Blackberry World. Please ensure that your device is connected to the wireless network and try again."
    even though im connected in my wifi. not just that my LOCK BUTTON on top of my phone wont work. 
    how to solve this problem? Thanks 
    Subject Title edited to reflect new topic.

    Hi and Welcome to the Community!
    There are actually a lot of public KBs that discuss that (and similar) error...rather than posting links to them all, I instead recommend you conduct your own search here:
    http://btsc.webapps.blackberry.com/btsc/microsites/microsite.do
    Hopefully your search results will contain something useful! There also are multiple existing threads on this site that discuss that exact error...your review of those might prove useful, and a search of this site, using the error message, error code, or symptom, should reveal all applicable existing threads to you.
    jezreelbacus wrote:
    not just that my LOCK BUTTON on top of my phone wont work. 
    Hmmm..."wont work"...hmmm...sorry, but I can think of too many different interpretations of that (physical, software, etc.). So please clarify your exact symptoms and then perhaps we can understand well enough to provide you with useful guidance.
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Exchange Online Protection and Public Folders

    Hi,
    We have just been migrated to Exchange Online Protection from FOPE and although users can now manage their own quarantines, they cannot do this for Mail Enabled Public Folders. Is this possible?
    Many Thanks

    Hi Paul,
    I replied to a post from you in another thread. It's easy to miss though, so here's what I said:
    "You should tell mail2web that there is an option in Exchange to hide public folders from IMAP clients. I'm an IT manager at a large software company with 50% of our users on Macs. We turned on the option to hide public folders from IMAP clients a while ago, long before the iPhone. It's worked very well and continues to work for iPhone people (like me!).
    There was no reason for us to make public folders viewable via IMAP, so hopefully the same will be true for mail2web."
    I'm actually really glad that Apple made this change. I want to see most of the folders at the inbox level in Exchange and with the Exchange switch turned on to hide public folders, there's no downside.
    Regards,
    fh

  • Access modifiers ignored !?!

    Hi
    please, have a look at the code below and let me know your opinions
    // ------------- source file 1 ------------------------
    package pckg1;
    public class Dog {
         final public static void main (String[] args) {
              pckg2.Puppy puppy = new pckg2.Puppy("Spot");
              System.out.println(puppy.getName());
    // ------------- source file 2 --------------------
    package pckg2;
    class Puppy {
         String name;
         public Puppy(String name) {
              this.name = name;
         String getName() {return name;}
    Each class belongs to a different package. Obviously if you compile Puppy first and attempt compiling Dog the compiler will complain about several things (class Puppy not being public, method getName() not being public, etc...).
    Now,
    if you change the Puppy class so that the necessary bits are public, re-compile Puppy and then Dog it will work.
    When you subsequently go back to Puppy and remove the added public access modifiers and re-compile JUST the Puppy class and try running Dog IT WILL STILL WORK AS IF EVERYTHING IN THE PUPPY CLASS WERE PUBLIC.
    I don't thing this is right. If the access modifiers cannot be relied on then the whole system is flawed.
    PS: Running on W2K, the behaviour observed on JRE 1.2.2_007, 1.3.0_02 as well as on 1.4.0-beta-b65.
    Cheers
    Ales Krestan

    Thanks for the response, but I hold different views on the matter. Although performance surely is of a great importance, it should not come at the expense of consistency.
    A few more thoughts on the same:
    1/ my understanding is that it is responsibility of the class loader to decide what to do in such cases during the resolution case. Apparently the application class loader of SUN's JVM ignores it and so does the extension class loader of the same JVM.
    2/ surprisingly (or rather expectedly) when attempting to load both classes (with the dodged version of Puppy) using the system class loader the JVM throws java.lang.IllegalAccessError.
    3) the same trick cannot be done with an interface. If you try to dodge an interface using the same principle and try to load it using the application class loader JVM will refuse to run (or load) the class that uses the dodged interface.
    4/ the class loader DOES other things, so why not to check the access modifiers as well. It should check if the class can be instantiated, for example. See the section 2.17.3 Linking: Verification, Preparation, and Resolution of the JVM specification.

  • What is the difference between access specifiers and access modifiers?

    what is the difference between access specifiers and access modifiers? are they same? if not what is the difference.

    Access Specifier are used to specifiy how the member variable ,methods or class to other classes.They are public ,private and protected.
    Access Modifier:
    1.Access
    2.Non Access
    Access:
    public ,private,protected and default.
    Non Access:
    abstract,final,native,static,synchronized,transient,volatile and strictfp

  • What is the difference of  public-read and  public-read protected

    I have noticed that the access of some variables in API document is public-read protected. I tried the following code. They seem all the same.
    class FatherClass{
    public-read var a;
    public-read protected var b;
    init{
        a=1;
        println(a);
        b=1;
        println(b);
    class SubClass extends FatherClass{
        init{
            a=4;
            println(a);
            b=4;
            println(b);
    var subClass=SubClass{};

    As you see in my code, subclass can write the variable with either public-read and public-read protected. What write access do the public-read protected widen? That's because your subclass is in the same script as the variable. Move the subclass to a separate script and it would not be able to write when the access is public-read.
    "public-read" = any code can read, code in the same script can write.
    "public-read protected" = any code can read, code in the same script, in the same package or in a subclass can write.

  • Private, protected Access Modifiers with a class

    Why cant we use private and protected access modifiers with a class?
    Thanks.

    Matiz wrote:
    >
    Public access allows you to extend a parent class in some other package. If you only want users to extend your class rather than instantiate it directly, make the class abstract and design for extension.Agreed. However, would the same argument be not true for the default access at the class level? No. Default access would only allow you to extend a parent class in the same package (as opposed to some other package).
    Now my confusion is why is a class allowed default access at the top level and not protected?Because protected for a top-level class makes no sense. The protected keyword provides member access to any other class in the same package and extending classes outside the package. A top-level class isn't a member of a class, by definition, so there's nothing that protected would do provide differently than public.
    So, the two access modifiers for a top-level class are public and default. Public allows access to the class outside the package, whereas default restricts access to the class within the package.
    ~

  • Protected access and Default access

    hi all,
    Can you tell exact difference between protected access and default access.
    Thanks in advance.

    default (for classes*), also known as "package" or "package private": accessible from within that class and other classes in the same package.
    protected: accessible from within that class, other classes in the same package, and subclasses.
    *Note that for interfaces, the "default" access is pubic, not "package private".                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Wat is the exact differences between clustered table and pooled table

    hi,
       can you tell me ravi...wat is the exact differences between clustered table and pooled table
    with regards//
    anilreddyg

    Hi Anil Reddy
    Pooled Tables, Table Pools, Cluster Tables, and Table Clusters
    These types of tables are not transparent in the sense that they are not legible or manageable directly using the underlying database system tools. They are managed from within the R/3 environment from the ABAP dictionary and also at runtime when they are loaded into application memory.Pool and cluster tables are logical tables. Physically, these logical tables are arranged as records of transparent tables. The pool and cluster tables are grouped together in other tables, which are of the transparent type. The tables that group together pool tables are known as table pools, or just pools; similarly, table clusters, or just
    clusters, are the tables which group cluster tables.Not all operations that can be performed over transparent tables can be executed over pool or cluster tables.
    For instance, you can manage these tables using Open SQL calls from ABAP, but not Native SQL.These tables are meant to be buffered and loaded in memory, because they are commonly used for storing internal control information and other types of data with no external (business) relevance. SAP recommends that tables of pool or cluster type be used exclusively for control information such as
    program parameters, documentation, and so on. Transaction and application data should be stored in transparent tables.
    Table Pools
    From the point of view of the underlying DBMS as from the point of view of the ABAP dictionary, a table pool is a transparent table containing a group of pooled tables which, when created, were assigned to this table pool.
    Field Type Description
    TABNAME CHAR(10) Table name
    VARKEY CHAR(n) Maximum key length n =< 110
    DATALN INT2(5) Length of the VARDATA record returned
    VARDATA RAW(m) Maximum length of the data varies according to DBMS
    Table Clusters
    Similarly to pooled tables, cluster tables are logical tables which, when created, are assigned to a table cluster. Therefore, a table cluster, or just cluster, groups together several tables of type clusters.Several logical rows from different cluster tables are brought together in a single physical record. The records
    from the cluster tables assigned to a cluster are thus stored in a single common table in the database.A cluster contains a transparent cluster key which must be located at the start of the key of all logical cluster tables to be included in the cluster. As well, a cluster contains a long field (VARDATA), which contains the
    data of the cluster tables for this key. If the data does not fit into a field, continuation records are created.
    Field Type Description
    CLKEY1 CHAR(*) First key fields
    CLKEY2 CHAR(*) Second key field
    CLKEYN CHAR(*) nth key field
    PAGENO INT2(5) Number of the next page
    TIMESTMP CHAR(14) Time stamp
    PAGELG INT2(5) Length of the VARDATA record returned
    VARDATA RAW(*) Maximum length of the data section; varies according to database system
    Working with Tables
    The dictionary includes many functions for working with tables. There are five basic operations you can perform on tables: display, create, delete, modify, copy. Please do not confuse displaying a table with displaying the table entries (table contents). In order to display a table, it must previously exist; otherwise the system will display an error message in the status bar. For the following example, the table TABNA is used. To display this table, from the main dictionary screen, enter the table name in the Object name
    input field with the radio button selected next to Tables. Then, click on the Display button at the bottom of the screen, or press the F7 function key, or, alternatively,
    select Dictionary object Display from the menu.
    In this screen, you can see table information such as
    ¨ Table type, shown next to the name of the object. In the example, it is a transparent table.
    ¨ Short text description.
    ¨ Name of the user who made the last change, and the date of the change.
    ¨ Master language.
    ¨ Table status. On the screen, you can see this table is saved and active.
    ¨ Development class. For information on development classes, refer to Chap. 6.
    Delivery class, which sets the maintenance group for the table. It controls how tables will behave during client copy procedures, upgrades, and so forth.¨
    Tab. Maint. Allowed flag, which indicates whether you can generate a screen for maintaining table entries.
    ¨Then, on the lower part of the screen, you can see the table fields with all associated characteristics such as:
    ¨ Field name.
    ¨ Key indicator. When set, this field is the primary key, or part of it.
    ¨ Data element.
    ¨ Basic data type.
    ¨ Length.
    ¨ Check table.
    ¨ Short text, describing the field.
    Additional information about the table can be displayed by selecting the corresponding functions from the menu or directly from the application toolbar, such as keys, indexes, or technical settings
    Standard table:
    The key access to a standard table uses a sequential search. The time required for an access is linearly dependent on the number of entries in the internal table.
    You should usually access a standard table with index operations.
    Sorted table:
    The table is always stored internally sorted by its key. Key access to a sorted table can therefore use a binary search. If the key is not unique, the entry with the lowest index is accessed. The time required for an access is logarithmically dependent on the number of entries in the internal table.
    Index accesses to sorted tables are also allowed. You should usually access a sorted table using its key.
    Hash table:
    The table is internally managed with a hash procedure. All the entries must have a unique key. The time required for a key access is constant, that is it does not depend on the number of entries in the internal table.
    You cannot access a hash table with an index. Accesses must use generic key operations (SORT, LOOP, etc.).
    Index table:
    The table can be a standard table or a sorted table.
    Index access is allowed to such an index table. Index tables can be used to define the type of generic parameters of a FORM (subroutine) or a function module.
    Just have a look at these links:
    http://help.sap.com/saphelp_nw04/helpdata/en/90/8d7304b1af11d194f600a0c929b3c3/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/74/83015785d811d295a800a0c929b3c3/frameset.htm
    Regards
    Sreeni

  • Difference between public void, private void and public string

    Hi everyone,
    My 1st question is how do you know when to use public void, private void and public string? I am mightily cofuse with this.
    2ndly, Can anybody explain to me on following code snippet:
    Traceback B0;//the starting point  of Traceback
    // Traceback objects
    abstract class Traceback {
      int i, j;                     // absolute coordinates
    // Traceback2 objects for simple gap costs
    class Traceback2 extends Traceback {
      public Traceback2(int i, int j)
      { this.i = i; this.j = j; }
    }And using the code above is the following allowed:
    B[0] = new Traceback2(i-1, 0);
    Any replies much appreciated. Thank you.

    1)
    public and private are access modifiers,
    void and String return type declarations.
    2)
    It's called "inheritance", and "bad design" as well.
    You should read the tutorials, you know?

  • Understanding the combination of inheritance, packages and access modifiers

    I am working on a problem to help my practical understanding of accessing inherited members and methods from a different package using both inheritance and instance variable.
    Unfortunately, I am totally lost when I tried to set this up and understand what was happening.
    Problem:
    Create a class named "classA" under package "pack1" with 4 members (int pub_a, int priv_a, int prot_a, int def_a) and methods (pub_func1, priv_func1, prot_func1, def_func1). Mark the members and methods with 4 different access specifiers (public, private, protected, and default)
    Create a class named "classB" under package "pack2", ClassB will inherit classA of package pack1. ClassB will have 2 members (int pub_b, int priv_b) and methods (pub_func2, prot_func2) with 2 different access specifiers (public, protected)
    Try accessing the members of class classA in package pack1 inside class classB of package pack2. Find out what members and methods are accessible and not-accessible through inheritance.
    Create an instance of class classA inside class classB of package pack2. Find out what members and methods are accessible and not-accessible through the instance.
    Note: In your solution, comment out the lines that are in-accessible with the actual error message at the top of the comment.
    So I produced the following code (I don't think i set this up right):
    //filename A.java
    package pack1;
    public class A {
         public int pub_a;
         private int priv_a;
         protected int prot_a;
         int def_a;
         public int pub_func1() {return 1;}
         private int priv_func1() {return 2;}
         protected int prot_func1() {return 3;}
         int def_func1() {return 4;}
    //filename B.java
    package pack2;
    import pack1.A;
    public class B extends A{
         public     int pub_b;
         private int priv_b;
         public int pub_func2() { return 5; }
         private int priv_func2() { return 6; }
         //directly inherited fields, at least one should be accessible?
         pub_a = 1;
         priv_a = 1;
         prot_a = 1;
         def_a = 1;
         int i;
         // directly inherited methods, at least one should be accessible?
         i = pub_func1();
         i = priv_func2();
         A a = new A();
         //not sure what's accessible here, as no error red underlines appear
         a.pub_a = 1;
         a.priv_a = 1;
         a.prot_a = 1;
         a.def_a = 1;     
    }I would be interested to know how one would approach and address this problem.

    //filename B.java
    package pack2;
    import pack1.A;
    public class B extends A{
         public     int pub_b;
         private int priv_b;
         public int pub_func2() { return 5; }
         private int priv_func2() { return 6; }
         //directly inherited fields, at least one should be accessible?
         pub_a = 1;//true
         priv_a = 1;// false
         prot_a = 1;//true
         def_a = 1;//false
         int i;
         // directly inherited methods, at least one should be accessible?
         i = pub_func1();//true
         i = priv_func2();//false
         A a = new A();
         //not sure what's accessible here, as no error red underlines appear
         a.pub_a = 1;//true
         a.priv_a = 1;//false
         a.prot_a = 1//false;
         a.def_a = 1;//false
    }Edited by: fun_with_me on May 31, 2008 8:30 AM

  • Change public share access to read only for public and full access to selected users

    Hi, new to the community just purchased a recertified WDMyCloud 2TB after my 2 years old MyBookLive 2TB HD died due to accidental power cable unplugging. I've got everything setup including MiniDLNA by following instructions on this forum and everything is working  exactly as I want it to except public share. I want public share to be set to read only access for public and full access to certain users (just myself at the moment) and having a "upload" folder within this share with full public access to everything in this folder would be a bonus. I tried login in to ftp with root user and removing write permission for public but that blocks me out as well. I'm sure it's possible by doing some majic on SSH but I wouldn't have a clue so hoping someone here would be able to help me out.

    Mr_Khan wrote:
    What i want is public to have read only access to file server. Public as in users who do not have a user account on mycloud. E.g someone who connects to to my home network for the first time and is able to browse and download content from public share. I'm aware of being able to set indivual access to shares for users like full access, read only and no access but public users won't have a user account.Through the My Cloud UI interface what you seek to do is not possible. The public share like all other share folders are an all or nothing affair when using the adminstration UI. When using the administration UI you do not have granular control on shared folders to limit non users to read only access or set permission levels for subfolders. The workaround to do what you seek and have the public folder set for read only is to change the folder settings via SSH. It may take some work to set the folder security so that users can read/write to the public folder while the guests only have read access. However, if you reboot the WD My Cloud or update the WD My Cloud firmware those settings may be reset back to the default settings where the entire public folder is read/write for all. There are way to prevent this but again it will take a bit of coding to do so via SSH. See this link (even though its for the WD My Book Live) for a starting point on how to use SSH to change the permission levels on the public folder. Another option if one doesn't go the SSH route is to turn off public sharing for the public folder then create a "guest" user account and give that "guest" account read only access to the public folder while all other user accounts have full read/write access.

  • Exact  difference between se09 and se10

    Hi all,
    i want to know the exact difference  between se09 and se10  .
    i know
    SE09 is the workbench transport requests transaction - here the developers can track changes to all ABAP workbench objects (dictionary, reports, module pools, etc). This is a developer-specific transaction and mostly all developers have access to this transaction.
    SE10 is the customizing request display transaction - this displays all the customizing requests in the system. Again, this could be restricted to Business analysts if required, since they would be doing most of the customizing changes in the system.
    but i think this is not the correct answer which is  already appear in the thread list
    recently sombady has answer like the one which i have mentioned above but the interviwer said that this is wrong.
    CAN ANYONE TELL ME THE EXACT ANSWER AND HELP ME OUT.
    Regards
    fareed

    Hi Fareed,
      First of all, i would say its a nice obsevation. As soon as i saw your post i started checking both transactions in seperate window and i found something interesting.
    My Observation is as follows:-
    <b>When we create a Transaction, apart from the Transaction Name, Program Name, Screen Number etc., we also can give someting called "AUTHORIZATION FOR CALLED TRANSACTIONS", under the menu: UTILITIES of the window.
    Also we can use TRANSACTION:SE97, Maintain Transaction call Authorization in CALL TRANSACTION. Here we maintain the list of TRANSACTION CALLED for our Calling Transaction.
    Now if you see, this list for Transaction SE09 and SE10, The Authorization for Called Transaction Differs a lot. Hence the difference bettween SE09 and SE10 is mainly the AUTHORIZATION Objects.</b>
    <b>NOTE:</b> This is my own observation, so there are chances of misinterpretation from my side, accounting to the human err. But this is something new to me too.
    Thanks and regards,
    RAVI :).
    PLEASE AWARD POINTS IF YOU FEEL MY SOLUTION TO YOUR QUESTION IS RIGHT $-).

  • Exact difference between VOimpl and VORowimpl and EO.

    Can anybody tell me whats the exact difference between
    VOimpl and VORowimpl and EO.
    Thanks

    Entity Object :BC4J entity objects encapsulate the business rules (validations, actions and so on) associated with a row in a database table, view, synonym or snapshot.
    View Object : (ViewImpl)
    In the simplest terms, a BC4J view object encapsulates a database query and provides iteration over and access to the view rows in its result set.
    View Row : ViewRowImpl :
    Represents a single row in a view object.
    For more Details see OA Developer Guide.
    Thanks

Maybe you are looking for

  • "save as" and "open"

    If I open Folder A, open a photo from Folder A, and edit that photo, when I'm finished and hit "SAVE", it doesn't save it to Folder A. It saves it to a folder many annoying mouse clicks away. It used to save the edited photo to whichever folder you r

  • Wake from Sleep to go into Hibernation is not working

    I have a user that has a T400s running windows 7 pro. I do not have any issues with the computer going to sleep or hibernation or resuming from either. The issue is when the user either puts the laptop to sleep or if he lets it go to sleep (by defaul

  • HT1386 Ipod is not showing up in the itunes interface

    This is garbage

  • Supplier Performance

    Hi SAP Gururs, Is there any standard report to view performance of the Suppliers. The report should have ideally the following fields: Vendor name Purchase order number Agreed delivery date Actual delivery date Quantity ordered Quantity remaining to

  • Images being "magically" replaced by other images

    I am using Aperture 2.4.1 and lately when I open a folder my thumbnails have been changing to different images on their own. Sometimes it happens automatically and sometimes I click on the image. For instance I will click on a photo of a person and t